Converting NUMBER column to boolean

3 views
Skip to first unread message

Serguei Cambour

unread,
Jul 9, 2018, 11:27:37 AM7/9/18
to Oracle enhanced adapter for ActiveRecord
I discovered a strange behaviour when querying a table containing a column of type NUMBER:
Here is what I get when running a simple query to figure out column types:

select * from SYS.ALL_tab_COLUMNS where owner='SOME_OWNER' and table_name='MY_TABLE';

- DATA_TYPE: NUMBER
- COLUMN_NAME: OPENING_STORE
- DATA_LENGTH: 22
- DATA_PRECISION: 1
- DATA_SCALE: 0
- NULLABLE: Y

The values for OPENING_STORE column I get are either 0 or 1.
But when querying it with ActiveRecord:

store = StoreInfo.first
puts store
.inspect


I get it as boolean: opening_store: false

#<StoreInfo id: 1, address: "Centre Commercial Englos les Géants", city: "Sequedin", country: "FRANCE", dir_first_name: nil, dir_last_name: nil, dir_signature: "Agathe, leader magasin", fax: nil, gps_x: 50.62806, gps_y: 2.9573769999999513, name: "Englos Sequedin", phone: "03 20 00 17 00", postal_code: "59320", region: "59 Nord", state: "null", store_id: "0070000100001", facebook_url: "https://www.facebook.com/decathlonsequedinenglos", web_site: "1", workshop: true, opening_store: false, mapregion_id: "FR-59", twitter_account: nil, store_reviews: true, ebooking_phone: nil, update_date: "2018-06-26 10:32:08", getting_here: "Zone commerciale Englos les Géants", address2: "avenue de la Boutillerie", display_contact_form: true, google_plus_account: nil, plus_kiosk_event_id: nil, store_size: nil, temporary_closed: "0", store_type: "DECATHLON", virtual_visit: nil>



Is it a normal behaviour for all the ActiveRecord objects or it is just Oracle specific one ?
Thank you.

Reply all
Reply to author
Forward
0 new messages