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):006:0> Address.first.cases
Sequel::DatabaseError: ODBC::Error: S0022 (207) [Microsoft][ODBC SQL Server 
Driver][SQL Server]Invalid column name 'address_id'.


It seems Sequel is using the conventional name for the primary key, though 
I tried to override it. What am I doing wrong ? 

by the way, Address.colunms returns thus:

irb(main):015:0> pp Address.
[:"Index adresse",
 :Nom,
 :"Nom complet",
 :Titre,
 :"Pr\xE9nom",
 :Rue,
 :Num,
 :Ligne2,
 :Code,
 :"Localit\xE9",
 :Pays,
 :"t\xE9l",
 :"t\xE9l2",
 :Natel,
 :fax,
 :fax2,
 :Web,
 :email,
 :langue,
 :"liste noire",
 :remarque,
 :"Personne physique",
 :"Personne morale",
 :Client,
 :"Client potentiel",
 :Correspondant,
 :"Correspondant actif",
 :Fournisseur,
 :"Prochain mailing",
 :"Nbre demploy\xE9s",
 :"Adresse morte",
 :"Client inactif",
 :"D\xE9biteur Mandant",
 :"Nomd\xE9biteur",
 :"Nom complet d\xE9biteur",
 :"Rue d\xE9biteur",
 :"Num d\xE9biteur",
 :"Ligne2 d\xE9biteur",
 :"Code d\xE9biteur",
 :"Localit\xE9 d\xE9biteur",
 :"Pays d\xE9biteur",
 :"t\xE9l d\xE9biteur",
 :"t\xE9l2 d\xE9biteur",
 :"Natel d\xE9biteur",
 :"fax d\xE9biteur",
 :"fax2 d\xE9biteur",
 :"email d\xE9biteur",
 :"langue d\xE9biteur",
 :"liste noire d\xE9biteur",
 :"remarque d\xE9biteur",
 :Responsable,
 :"date mise \xE0 jour",
 :monnaie,
 :smallentity,
 :"rappelpriorit\xE9",
 :"rappeld\xE9signation",
 :TVA,
 :"pr\xE9f\xE9rences",
 :datecreation,
 :ID_destinataire_favori,
 :Remarques_corr,
 :ID_destinataire_copie,
 :Remplacant,
 :chocolat,
 :Avec_interlocuteur,
 :carte_noel,
 :Mailing_limite,
 :Personne_morale,
 :timestamp,
 :presse,
 :Maling_a_cette_adresse,
 :Resp_adm,
 :Resp_adm2,
 :ireland] 



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.

Reply via email to