[Nitro] Problems...

Jeff Wood jeff.darklight at gmail.com
Sun Aug 28 11:07:13 EDT 2005


Jeff Wood wrote:

> I played a bit more with my script ... and it seems that the magical 
> goodness of Og redefining tables doesn't work for sqlite ... so, when 
> I blew away the sample database, it recreated things and it seems to 
> work now.
>
> I think you should add some kind of an easy to read error message that 
> the class definitions don't match up with the database model, and that 
> the database model is not alterable ( as easily ) in sqlite
>
> Anyways, thanks for your help.
>
> Oh, also, I was trying to follow the example where you use User[ 
> 'value from name field' ] and it doesn't seem to like that ... yet 
> another incompatibility with sqlite?
>
> Thanks again.
>
> j.
> _______________________________________________
>
>Nitro-general mailing list
>Nitro-general at rubyforge.org
>http://rubyforge.org/mailman/listinfo/nitro-general
>  
>
Figured I should post code...

--SCRIPT--
require 'rubygems'
require 'og'

db = Og.setup( :store => :sqlite, :name => 'blah' )

class User
    property :name, String
    property :pass, String
    property :age, Fixnum
    has_many :comments, Comment

    def initialize( name, pass, age )
        @name = name
        @pass = pass
        @age = age
    end
end

class Comment
    property :title, String
    property :body, String
    belongs_to User

    def initialize( title, body )
        @title = title
        @body = body
    end
end

db.manage_classes( User, Comment )

a = User.create( "joe", "shhh", 13 )
b = Comment.create( "comment #2", "testing 4 5 6" )

a.comments << b

puts a.name
puts a.pass
puts a.age
puts "Comments Length : #{ a.comments.length }"
a.comments.each { |curr| puts "#{ curr.title } -- #{ curr.body }" }


c = User['joe']
puts c.name
puts c.pass
puts c.age
puts "Comments Length : #{ c.comments.length }"
c.comments.each { |curr| puts "#{ curr.title } -- #{ curr.body }" }
--SCRIPT--

The blow up is at the c = User['joe'] line...

the error is:

================ SQLite3::SQLException =====================
c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0-mswin32/lib/sqlite3/errors.rb:94:in 
`check'
            raise ( EXCEPTIONS[result] || SQLite3::Exception ), msg
c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0-mswin32/lib/sqlite3/statement.rb:70:in 
`initialize'
          Error.check( result, @db )
c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0-mswin32/lib/sqlite3/database.rb:183:in 
`new'
          stmt = @statement_factory.new( self, sql )
c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0-mswin32/lib/sqlite3/database.rb:183:in 
`prepare'
          stmt = @statement_factory.new( self, sql )
c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0-mswin32/lib/sqlite3/database.rb:274:in 
`query'
          result = prepare( sql ).execute( *bind_vars )
c:/ruby/lib/ruby/gems/1.8/gems/og-0.22.0/lib/og/store/sqlite.rb:77:in 
`query'
        return @conn.query(sql)
c:/ruby/lib/ruby/gems/1.8/gems/og-0.22.0/lib/og/store/sql.rb:307:in `load'
        res = query "SELECT * FROM #{klass::OGTABLE} WHERE 
#{klass.pk_symbol}=#{pk}"
c:/ruby/lib/ruby/gems/1.8/gems/og-0.22.0/lib/og/entity.rb:80:in `[]'
          ogmanager.store.load(pk, self)
C:\Documents and Settings\jwood\TestRuby\ogtest.rb:45
    c = User['joe']
c:\ruby\lib\ruby\site_ruby\1.8/rubygems/custom_require.rb:21:in `require__'
        require__ path
c:\ruby\lib\ruby\site_ruby\1.8/rubygems/custom_require.rb:21:in `require'
        require__ path
 
=============================================
Exception: no such column: joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/nitro-general/attachments/20050828/bdb16601/attachment.html 


More information about the Nitro-general mailing list