On Saturday, November 5, 2016 at 6:24:16 PM UTC+1, Михаил Касьянов wrote:
>
> Hello, all.
> I have the application, which uses SQLite database with OID (aka ROWID aka 
> _ROWID_) as primary key. I try to use Sequel instead of sqlite3 gem and 
> can't get this key.
> SQL example from sqlite3: "SELECT `oid` AS `id`, * FROM `staff`". Is there 
> an option to get OID through Sequel "db[:staff]" queries?
>

Seems to work here, except that ruby-sqlite3 seems to want to always call 
it rowid, so you probably should just use rowid instead of oid.  Example:

 $ ruby bin/sequel -E sqlite:/
I, [2016-11-05T23:38:52.154791 #78936]  INFO -- : (0.000875s) PRAGMA 
foreign_keys = 1
I, [2016-11-05T23:38:52.155012 #78936]  INFO -- : (0.000057s) PRAGMA 
case_sensitive_like = 1
Your database is stored in DB...
irb(main):001:0> DB.create_table(:foo){String :a}
I, [2016-11-05T23:39:08.633594 #78936]  INFO -- : (0.000483s) CREATE TABLE 
`foo` (`a` varchar(255))
=> nil
irb(main):002:0> DB[:foo].insert("abc")
I, [2016-11-05T23:39:15.506369 #78936]  INFO -- : (0.000397s) SELECT 
sqlite_version()
I, [2016-11-05T23:39:15.506820 #78936]  INFO -- : (0.000164s) INSERT INTO 
`foo` VALUES ('abc')
=> 1
irb(main):003:0> DB[:foo].select(:oid, :a).all
I, [2016-11-05T23:39:33.408789 #78936]  INFO -- : (0.000266s) SELECT `oid`, 
`a` FROM `foo`
=> [{:rowid=>1, :a=>"abc"}]
irb(main):004:0> DB[:foo].select_map([:oid, :a])   
I, [2016-11-05T23:40:02.038525 #78936]  INFO -- : (0.000209s) SELECT `oid`, 
`a` FROM `foo`
=> [[nil, "abc"]]
irb(main):005:0> DB[:foo].select_map([:rowid, :a])
I, [2016-11-05T23:40:09.534798 #78936]  INFO -- : (0.000215s) SELECT 
`rowid`, `a` FROM `foo`
=> [[1, "abc"]]

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to