<     May 2009     >
Su Mo Tu We Th Fr Sa
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
00:41 kaykay joined
01:39 ducktyped_ joined
03:03 pusewicz joined
04:20 pusewicz joined
04:20 iv_s joined
04:23 ducktyped joined
05:29 kupa joined
05:38 OnO joined
07:10 exploid joined
08:07 hydrow_ joined
08:12 aorist_ joined
08:34 auslander joined
08:38 auslander left
09:23 deedubs joined
09:24 deedubs left
09:49 paullamb joined
10:02 aorist_ left
10:06 mynyml joined
10:07 <mynyml> is there a way to load a sql schema into an in memory sqlite db?
10:08 <Death_Syn> i'd do it via migrations
10:18 <mynyml> Death_Syn: that'd be ideal but i can't.
10:19 <mynyml> closest i can get is a sql schema dump
10:24 <bougyman> sqlite3 the.db < the.sql.dump ?
10:24 <bougyman> i'd assume that would work, though i've never tried.
10:35 <Death_Syn> he's trying to load it into a memory-based db
10:36 <bougyman> oh
10:36 <bougyman> wild
10:36 <exploid> Sequel["sql goes here"] ?
10:47 OnO joined
10:56 <mynyml> exploid: hm! looks like i was looking too hard. trying it now
10:59 ducktyped_ joined
11:10 <mynyml> exploid: works like a charm. thx
11:11 <mynyml> my specs are now 10x faster (letterally)
11:12 <pusewicz> what's the easiest way to process data in batches?
11:15 iv_s joined
11:33 <jason^> is there a way to do an insert ignore with sequel?
12:02 kaykay joined
12:08 Lyfe_ joined
12:28 <jeremyevans> jason^: http://sequel.rubyforge.org/rdoc-adapters/classes/Sequel/MySQL/DatasetMethods.html#M000190
12:29 stimble joined
12:30 stimble_ joined
12:51 ducktyped joined
13:09 pusewicz_ joined
13:35 <jason^> jeremyevans: thanks, i didn't realize that was in there
14:23 bman joined
14:23 <bman> jeremyevans:hi
14:28 stimble joined
14:30 jdunphy joined
14:40 kupa joined
14:49 bman_ joined
14:53 bman joined
15:09 tibbon joined
15:10 <tibbon> If I've set a column an attribute as unique => true, and then I try to insert something that's a duplicate, how do I ignore the error and keep going? The user doesn't need to know that I've already got the entry. Getting the "SQLite3::SQLException column FOO is not unique" error. I'm using Sinatra as my framework.
15:17 <exploid> tibbon: wrap your call in a begin rescue block and just ignore the exception?
15:18 <tibbon> exploid: Around the line that I'm actually trying to call the insert, not somewhere in the model right?
15:19 <tibbon> exploid: Got it, works perfectly. Thanks!
15:20 <exploid> tibbon: no problem
15:20 <exploid> tibbon: you might want to catch more than one exception type though, in case it would be an exception other than the one for duplicate record
15:20 <exploid> tibbon: not sure what the exceptions are
15:22 hgimenez joined
15:28 <jeremyevans> tibbon: You want to catch Sequel::DatabaseError, since that is what should be raised for all database exceptions
15:28 <jeremyevans> bman: Hi
15:28 <tibbon> jeremyevans: Stupid question, but what's the syntax of that line?
15:29 <exploid> raise Sequel::DatabaseError => exception_var
15:29 <jeremyevans> tibbon: begin; dataset.insert(...); rescue Sequel::DatasetError; nil; end
15:29 <tibbon> jeremyevans: perfect. Thank you much
15:30 <bman> jeremyevans: did something change for column maps... i get this error: undefined method `map' for nil:NilClass
15:35 kupa_ joined
15:37 <jeremyevans> bman: Can you pastie?
15:44 <bman> http://p.ramaze.net/23620
15:45 <bman> although the error is coming from a ramaze helper, it points to the columns.map... which is why i'm asking has something broken in sequel that is causing this... worked fine in previous version of sequel
15:45 <jeremyevans> bman: That should have only worked if you were using set_schema in the model
15:46 <bman> ah, yes... and i removed that, since you mentioned that it's discouraged to use set_schema
15:46 <jeremyevans> bman: I'm not sure what the purpose of that code is, but there's definitely a better way to do it.
15:46 <bman> ok
15:46 <jeremyevans> bman: What are you trying to do?
15:47 <bman> it's generating a html form from a model
15:47 <jeremyevans> OK. You can get the columns from Model.columns
15:47 <jeremyevans> bman: If you want column related information, use Model.db_schema
15:47 <bman> and it returns the column data type
15:48 <jeremyevans> bman: Model.columns.map{|c| Model.db_schema[c]} may get you close to what you want
15:48 <bman> i.e. bit, i make a checkbox, varchar make a input box, etc
15:48 <jeremyevans> bman: The :type entry in the resulting hash will be something like :string, :integer, etc.
15:49 <jeremyevans> bman: And using checkboxes for booleans is a bad idea unless the boolean is NOT NULL
15:49 <bman> what would you suggest
15:51 <jeremyevans> bman: For booleans that can be NULL, a select box with 3 options (NULL/empty, true, and false) is how I handle that
15:51 <jeremyevans> bman: The :allow_null entry in the hash shows whether nulls are allowed
15:52 <bman> hmmm, and your web customers/users base adapt to that pretty well?
15:53 <jeremyevans> bman: Generally these are admin forms, but I haven't had complaints from the users who have to use them.
15:53 OnO joined
15:54 <bman> jeremyevans: is there a hash that contains all the possible :types... i want to create a case statement for my forms generator
15:54 <bman> or do i have to look at the code?
15:54 <jeremyevans> bman: I don't believe there is currently.
15:55 <bman> are types based on the adapter, or are they standard across all adapters
15:55 <jeremyevans> bman: Database#schema_column_type is where you should look. I believe it is standard across adapters
15:55 <bman> k
15:56 <bman> you don't have a form generator up your sleeve somewhere do you :) ... (no need to re-invent)
15:57 <jeremyevans> bman: Scaffolding extensions has one you could probably use
15:57 <bman> so, i'd have to hack it out of your code since it's not ramaze 2009.04 ready?, correct?
15:57 <jeremyevans> bman: You might have to use quite a bit of that code though, since it's pretty abstracted in order to support both Sequel and AR
15:58 <jeremyevans> bman: The form generation shouldn't be specific to any web framework
15:58 <jeremyevans> bman: The issues with Ramaze 2009.04 are probably in the rendering. The form generation is the same on all 5 supported frameworks
15:58 tibbon_ joined
15:59 <bman> k
15:59 bman_ joined
16:00 pusewicz joined
16:00 bman__ joined
16:09 <ddollar> wondering if someone can give me a hand.. i have an array like ['foo', 'bar', 'fred'] and i want to get a where clause of WHERE (col1 LIKE '%foo%' OR col1 LIKE '%bar%' OR col1 LIKE '%fred%')
16:13 <jeremyevans> ddollar: dataset.grep(:col1, %w'foo bar fred')
16:13 <ddollar> jeremyevans: awesome, that's way simpler than what i was trying to do :P
16:13 <ddollar> thanks
16:14 <jeremyevans> ddollar: Oops, that's not exactly what you want, though
16:14 <ddollar> do i need to add the %
16:14 <ddollar> 's?
16:14 <jeremyevans> ddollar: dataset.grep(:col1, %w'foo bar fred'.map{|x| "%#{x}%"})
16:15 <jeremyevans> ddollar: And you may want to escape the % inside x as well:
16:15 <jeremyevans> ddollar: dataset.grep(:col1, %w'foo bar fred'.map{|x| "%#{x.gsub('%', '%%')}%"})
16:16 <jeremyevans> ddollar: I'm assuming your database is fairly small?
16:16 <ddollar> yeah
16:16 <ddollar> very
16:16 <ddollar> only a few hundred rows
16:16 <jeremyevans> ddollar: Then performance shouldn't be an issue
16:17 <ddollar> yup.. it works great as manual sql, im just trying to convert the project to sequel so i can stop building sql by hand :)
16:26 <mynyml> anyone knows where i could find simple docs for mime type handling?
16:27 <mynyml> i'm seeing :provides in the source for HTTP_ACCEPT ...
16:27 <mynyml> just wondering if there's a simple way to handle mime types. basically i need to allow for xml and json
16:28 <jeremyevans> mynyml: This is #sequel :)
16:28 <mynyml> *sign*
16:28 <mynyml> *sigh*
16:28 <mynyml> sorry about that
16:44 kaykay joined
17:01 kupa joined
18:12 mitkok joined
18:27 exploid joined
18:29 Mathetes joined
18:31 kupa joined
18:32 kaykay joined
19:20 aorist joined
19:30 <hgimenez> jeremyevans, hi
19:33 <hgimenez> jeremyevans, wondering if you had any thoughts on those patches
19:39 kotrin joined
19:49 <kupa> jeremyevans: Just dumped 1.0.3 merb_sequel which adds rspec examples wrapped in transactions so model specs are fast(er)! :-), thanks Jeremy.
20:14 <jeremyevans> hgimenez: I'm sorry, I haven't had a chance to look at them yet
20:15 <jeremyevans> kupa: Thanks!
20:39 <jeremyevans> hgimenez: I merged your changes, thanks!
20:47 <hgimenez> jeremyevans, sorry, was gone. Thank you, that's great!
22:59 kaykay joined
23:18 blakemizerany joined
23:22 aorist joined
23:44 kotrin joined
23:49 tibbon joined