Here is a patch that works for me: http://github.com/smeder/dm-core/commit/ed844cc15f08686b8c1ea64658a9a2cb26b9a73c
(based off 0.10.2) /Sam On Apr 10, 7:48 pm, Sam <[email protected]> wrote: > I've got a Postgres database that makes use of the schema construct, > e.g. a typical table name might be site.subjects. Now, as far as I can > tell Datamapper has no explicit support for this. The first issue I am > running into is getting the storage_name right. The default naming > convention will obviously not work, so I tried working around this by > mapping the namespace construct in postgres (schema) to a namespace > construct in Ruby (module) using the following convention: > > adapter.resource_naming_convention = lambda do |name| > > Extlib::Inflection.pluralize(Extlib::Inflection.underscore(name)).gsub('/', > '.') > end > > This will create the correct string when I use something like > > module Site > class Subject > ... > end > end > > to declare the model. My next issue is that the DataObjectsAdapter in > Datamapper quotes the table name when putting together the SQL > statements, e.g. > > statement = "SELECT #{columns_statement(fields, qualify)}" > statement << " FROM > #{quote_name(query.model.storage_name(name))}" > > which makes it impossible to specify a schema: > > ~ ERROR: relation "site.subjects" does not exist > LINE 1: SELECT "id", "sex", "dob", "active" FROM "site.subjects" > ORD... > > My questions now is how to best fix this? Should I change the postgres > adapter to use a different quoting function which doesn't also quote > the '.' in schema.table? Would such a patch be accepted? > > /Sam -- You received this message because you are subscribed to the Google Groups "DataMapper" 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/datamapper?hl=en.
