Hi Xavier, > I am trying to generate SQL to form part of a trigger definition. > Given the following array: > > [ > Post.title, # Property > Post.author.name # Query::Path > ] > > I'm trying to get something like: > > SELECT posts.title, authors.name FROM posts INNER JOIN authors ON > posts.author_id = posts.id > > There is enough information in the array to construct that SQL (via the > .relationships property of Path), but it feels like I would be > duplicating some part of DM by writing query generation myself, > especially calculating the joins. > > I'm not sure which part of the code to look though, can anyone point me > in the right direction?
The best place to look is inside the dm-do-adapter, which is responsible for generating (mostly) ANSI compliant SQL. It provides the base class that other adapters like dm-sqlite-adapter use and override small pieces to deal with DB specific quirks. The code does assume a DM::Query object is passed in, and may not be particularly straight forward. There's a few issues Jordan Ritter (jpr5) and I are working through wrt how many-to-many joins are generated, and it's become clear to me that after we get this specific issue resolved we need to revisit SQL generation and refactor or perhaps even rewrite it. If you have specific suggestions or requests regarding SQL generation now would be the perfect time to start discussing them. -- Dan (dkubb) -- 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.
