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.

Reply via email to