09:27
Swimming_Bird joined
12:49
<djanowski>
hello all. trying to use sequel with oracle XE, are there any limitations?
12:49
<djanowski>
basically the SQL generated for an ALTER TABLE is different from the expected
14:05
<jeremyevans>
djanowski: I've never tried. I know there are Sequel users using Oracle, but it wouldn't surprise me if not all ALTER TABLE commands work on Oracle.
14:06
<jeremyevans>
djanowski: I don't have access to an Oracle installation, so I can't test it
14:06
<djanowski>
jeremyevans: yeah it looks like it's not working. there's a slight difference when you add a column. nevermind, i'll test with the team and hopefully we can come up with a patch
14:06
<djanowski>
jeremyevans: a good patch would mean some refactoring on alter_table_sql
14:07
<djanowski>
otherwise it's hard to override for a single case
14:07
<jeremyevans>
djanowski: In general, you should just have to override it in the shared Oracle adapter
14:07
<jeremyevans>
djanowski: That's what the other adapters do
14:07
<djanowski>
jeremyevans: override the whole method?
14:07
<jeremyevans>
djanowski: The probability that it requires a change to Sequel core is unlikely
14:08
<jeremyevans>
djanowski: Basically, you just override it to handle the cases that need to be handled differently, and call super for the other cases
14:08
<jeremyevans>
djanowski: Look how it is overridden in the other shared adapters
14:09
<djanowski>
jeremyevans: still not very clean, in this case we'd only need to override one part of the `case`, not the whole ALTER TABLE statement
14:10
<jeremyevans>
djanowski: Which particular case isn't working?
14:10
<djanowski>
jeremyevans: ALTER TABLE "table" ADD COLUMN "foo" INTEGER
14:10
<djanowski>
jeremyevans: that's what sequel is trying to execute
14:10
<jeremyevans>
djanowski: What's the Oracle syntax needed?
14:10
<djanowski>
but oracle doesn't want ADD COLUMN but simply ADD
14:11
<jeremyevans>
djanowski: So you'd use case, override it for :add_column, and call super in the else
14:12
<jeremyevans>
djanowski: If the ADD/ADD COLUMN distinction affected more than one database, I'd think about supporting it in Sequel core
14:12
<djanowski>
jeremyevans: oh, sorry, no, i didn't mean that we'd need to support it
14:12
<jeremyevans>
djanowski: However, if it is just for Oracle, it's better just to override the whole add_column case in the adapter
14:12
<djanowski>
simply that using the case doesn't look very clean to me in terms of being able to easily override it
14:13
<djanowski>
i'd be duplicating the rest of the ALTER TABLE syntax
14:13
<djanowski>
s/syntax/statement
14:13
<jeremyevans>
djanowski: Yes. A whole line. Wow. :p
14:13
<jeremyevans>
djanowski: Really, it's not that bad
14:14
<djanowski>
jeremyevans: i agree, the world has other problems to worry about :)
14:14
<djanowski>
but you do agree that it's not super clean, right?
14:14
<djanowski>
if that line were doing more things, for example
14:14
<jeremyevans>
djanowski: Yes, it could be cleaner, but there's a tradeoff there
14:15
<jeremyevans>
djanowski: If it was more than one line, I might consider a core patch, but in this case, I don't think it is worth it
14:16
<djanowski>
jeremyevans: ok, no problem, it's good to know beforehand
14:16
<djanowski>
jeremyevans: thanks as always
14:16
<jeremyevans>
djanowski: No problem :)
15:34
<djanowski>
jeremyevans: # File lib/sequel/adapters/shared/oracle.rb, line 114
15:35
<djanowski>
jeremyevans: at what point does the dataset become associated with a sequence?
15:35
<djanowski>
not sure how opts[:sequence] becomes true
15:38
<jeremyevans>
djanowski: The sequence method (called manually), see line 129
15:39
<djanowski>
jeremyevans: right, so Sequel::Model never uses it when inserting a new record?
15:41
<djanowski>
jeremyevans: a bit more `ack`ing shows this: set_dataset dataset.sequence(:seq_albums_id)
15:41
<djanowski>
jeremyevans: that did it
15:41
<jeremyevans>
djanowski: If using Sequel::Model's with Oracle, I believe you need to set the sequence on the dataset so that the correct primary key value is returned when creating records
15:42
<jeremyevans>
djanowski: This isn't required on most other databases
15:42
<djanowski>
jeremyevans: is this something that could be somehow built in? maybe the adapter would be able to set the dataset?
15:42
<jeremyevans>
djanowski: If there's a good way to determine the sequence for a given table automatically, I wouldn't be against doing that
15:42
<jeremyevans>
djanowski: That's how the postgres adapter works.
15:43
<jeremyevans>
djanowski: But I don't know how to do it on Oracle, or have any ability to test it, and nobody has contributed any code to do so
15:43
<djanowski>
jeremyevans: absolutely
15:43
<jeremyevans>
djanowski: So on Oracle, it needs to be set manually
15:43
<djanowski>
checking the postgres adapter now
15:43
<djanowski>
jeremyevans: would you be interested in getting access to an oracle instance to run all of the sequel suite on it?
15:44
<jeremyevans>
djanowski: Sure
15:46
<merboutpost>
jeremyevans: is there a way how to run migration to see the SQL but not execute the migration?
15:47
<jeremyevans>
merboutpost: No
15:47
<jeremyevans>
merboutpost: You'd have to setup a dummy database
15:47
<jeremyevans>
merboutpost: Getting the SQL is easy, just add a logger
15:47
<jeremyevans>
merboutpost: But making it so it doesn't execute is tricky
15:47
<merboutpost>
jeremyevans: no problem, just quick reality check :-)
15:48
<jeremyevans>
merboutpost: Generally, if you have a test database, just run it on that with a logger
15:48
<merboutpost>
jeremyevans: yep that what i do, well I do sequel -E currently
15:49
<jeremyevans>
merboutpost: sequel -E just adds a standard output logger :)
15:52
<merboutpost>
I noticed that the up/down methods are actually evaluated in the different context than the migration
15:54
<jeremyevans>
merboutpost: Well, yes and no
15:54
<jeremyevans>
merboutpost: A migration acts as a proxy for the database
15:54
<merboutpost>
jeremyevans: I defined the LANGUAGES constant, but I need to qualify it
15:54
<jeremyevans>
merboutpost: So methods get send to the database using method_missing
15:55
<merboutpost>
jeremyevans: Ah..
15:55
<jeremyevans>
merboutpost: But constant lookup does not
15:55
<jeremyevans>
merboutpost: We could add a const_missing method to work around that, I suppose
15:55
<merboutpost>
jeremyevans: no neeed, I used AddMetadataToGalleriesMigration::LANGUAGES
16:14
Swimming_Bird_ joined
16:41
<josh0x0>
how can I get different models to use different databases? I tried setting db= ANOTHER_DB in one model, but it appears setting db = ANOTHER_DB2 in another model sets it for all models
16:45
<bougyman>
yeah, DB does.
16:45
<bougyman>
set the connection to a different hing.
16:45
<bougyman>
DB is the default if the model isn't explicitly set to a connection.
16:45
<bougyman>
so explicitly set it.
16:51
<jeremyevans>
josh0x0: class Model1 < Sequel::Model(DB1); end; class Model2 < Sequel::Model(DB2); end
16:54
<jeremyevans>
josh0x0: class Model1 < Sequel::Model; self.db = DB1; end; class Model2 < Sequel::Model; self.db = DB2; end # should also work
16:55
<jeremyevans>
josh0x0: First method is preferred as it results in one fewer query
16:55
<josh0x0>
okay. i was using the :table_name before as an argument to Sequel::Model not a Database (DB)
16:55
<josh0x0>
jeremyevans: i tried the 2nd option. somewhere the DB for one of my models is being set to DB2 after I originaly set it to DB1
16:56
<jeremyevans>
josh0x0: Can you provide a self contained example showing the problem?
16:56
<jeremyevans>
josh0x0: Also, you can do class Model1 < Sequel::Model(DB1[:table_name]); end;
16:58
<jeremyevans>
josh0x0: Also, make sure you are using self.db = and not db = inside your models
16:58
<jeremyevans>
josh0x0: local variable creation instead of assignment method call and all that
16:59
<jeremyevans>
Gotta go, leaving for the airport to go to MWRC
17:43
Swimming_Bird joined
18:17
<jeremyevans>
At the airport, flight leaves in 45 minutes
18:18
<jeremyevans>
Sacramento's airport provides free WiFi, unlike most other airports I've been through
19:00
Swimming_Bird joined
20:21
Swimming_Bird joined
20:59
Swimming_Bird joined