On May 29, 6:01 am, Yvon Thoraval <[email protected]> wrote:
> Hey all,
>
> that's my first try of Sequel and i want to know how to debug.
>
> my table is really simple :
>
> DB = Sequel.sqlite("#{WATCH_DB}")
>
>     DB.create_table :applications do
>       primary_key :id
>       String  :name
>       String  :displayed_name
>       String  :path
>       String  :bundle_identifier
>       String  :bundle_version
>       Time    :modification_date
>       Time    :timestamp
>     end
>
> and then i populate it with one row only :
>
> DB[:applications].insert(applications_fs.first)
>
> "applications_fs.first" being a hash with a lot more keys than needed by the
> database.

You can't do that.  You need to use a hash with only the keys that
match the columns, so you have to filter the hash first.  I don't
think that's the reason for the error message, though.

> the values for the used keys being :
>
>  :name=>"Address Book.app",
>  :displayed_name=>"Carnet d\xE2\x80\x99adresses",
>  :path=>"/Applications/Address Book.app",
>  :bundle_identifier=>"com.apple.AddressBook",
>  :bundle_version=>"868",
>  :modification_date=>2009-07-25 07:36:53 +0200,
>  :timestamp=>2010-05-29 14:39:10 +0200,
>
> and i got the following error :
>
> Sequel::DatabaseError: SQLite3::SQLException: near ",": syntax error
>
> method check    in errors.rb at line 62
> method initialize    in statement.rb at line 40
> method new    in database.rb at line 160
> method prepare    in database.rb at line 160
> method execute    in database.rb at line 187
> method block (2 levels) in execute_insert    in sqlite.rb at line 80
> method log_yield    in database.rb at line 450
> method block in execute_insert    in sqlite.rb at line 80
> method hold    in threaded.rb at line 84
> method synchronize    in database.rb at line 553
> method _execute    in sqlite.rb at line 105
> method execute_insert    in sqlite.rb at line 80
> method execute_insert    in actions.rb at line 400
> method insert    in actions.rb at line 199
> method <main>    in applications_watch_create_dbs_new.rb at line 13  <<<
> tjis is the "DB[:applications].insert(applications_fs.first)" (insert line)
>
> could it be due to some UTF-Mac versus UTF-8 discrepency as the above :
>  :displayed_name=>"Carnet d\xE2\x80\x99adresses"
> ----------------------------------------^^^^^^^^^^^^------------

Add a database logger and see what SQL it is producing.

  require 'logger'
  DB.loggers << Logger.new($stdout)

If it is really the cause of an encoding issue for that string, it's
not Sequel's fault as Sequel is using the quote method provided by
ruby-sqlite3.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to