Thank you for your quick reply.
I tried what you suggest, but it's still not working: I now get a different
error, though :
irb(main):004:0* Address.columns
Sequel::DatabaseError: ODBC::Error: 37000 (170) [Microsoft][ODBC SQL Server
Driver][SQL Server]Line 1: Incorrect syntax near '1'.
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sequel-4.4.0/lib/sequel/adapters/odbc.rb:41:in
`run'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sequel-4.4.0/lib/sequel/adapters/odbc.rb:41:in
`block (2 levels) in execute'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sequel-4.4.0/lib/sequel/database/logging.rb:33:in
`log_yield'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sequel-4.4.0/lib/sequel/adapters/odbc.rb:41:in
`block in execute'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sequel-4.4.0/lib/sequel/database/connecting.rb:229:in
`block in synchronize'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sequel-4.4.0/lib/sequel/connection_pool/threaded.rb:104:in
`hold'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sequel-4.4.0/lib/sequel/database/connecting.rb:229:in
`synchronize'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sequel-4.4.0/lib/sequel/adapters/odbc.rb:39:in
`execute'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sequel-4.4.0/lib/sequel/dataset/actions.rb:795:in
`execute'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sequel-4.4.0/lib/sequel/adapters/odbc.rb:104:in
`fetch_rows'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sequel-4.4.0/lib/sequel/dataset/actions.rb:143:in
`each'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sequel-4.4.0/lib/sequel/dataset/actions.rb:75:in
`columns'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sequel-4.4.0/lib/sequel/model/base.rb:136:in
`columns'
from (irb):4
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sequel-4.4.0/bin/sequel:234:in `<top
(required)>'
from C:/Ruby200/bin/sequel:23:in `load'
On Monday, 25 November 2013 18:59:40 UTC+1, Jeremy Evans wrote:
>
> On Monday, November 25, 2013 7:02:43 AM UTC-8, Giovanni Gervasio wrote:
>>
>> I am trying to find an ORM to wrap around a legacy database with table
>> and column names containing spaces and latin-1 encoded non-ascii characters
>> like [Indes du cas] or [Référence correspondant].
>>
>> Clearly, the right thing to do would be to rename everything according to
>> some sensible convention but, unfortunately, this is not an option for the
>> moment.
>>
>> The database is stored in a Microsoft SQL server and is accessed by a
>> very large MS access application.
>>
>> I have tested sequel and found with my delight that it is very easy to
>> connect to the database and perform queries. I used the 'odbc' adapter as
>> in 'odbc:///odbc_name?db_type=mssql'
>>
>> The problems appear, however, when I try imposing a model. I used the
>> following code for modelling a three-level hierarchy:
>>
>> class Dossier < Sequel::Model :Dossiers
>> set_primary_key ["Index dossier".to_sym]
>> many_to_one :cas, :key=>"Index du cas".to_sym
>> end
>>
>> class Cas < Sequel::Model
>> set_primary_key ["Index du cas".to_sym]
>> many_to_one :address, :key=>:IndexduMandant
>> one_to_many :dossiers
>> end
>>
>> class Address < Sequel::Model :ADRESSES
>> set_primary_key ["Index adresse".to_sym]
>> one_to_many :cases
>> end
>>
>>
>> and i get
>>
>> irb(main):004:0> Address.first.cases
>> NoMethodError: undefined method `Index adresse' for #<Address:0x26e2e58>
>>
>>
> This means there is no method of that name. You set this as the primary
> key of the Address model, so obviously you expect this to be a column name.
> By default on Microsoft SQL server, Sequel mangles identifiers, but in
> your case you probably want to turn that off:
>
> DB.identifier_input_method = nil
> DB.identifier_output_method = nil
>
> I would try that first. If it still doesn't work, please provide the
> output of:
>
> Address.columns
>
> 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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.