Hi Ted. Thanks for your replying! I am actually not trying to do anything exceptional. Just considering writing my own datamapper adapter for tokyo tyrant and I would like to use the same operators that come with TT's API.
For example: QCSTREW - query condition: string ends with which I'd like to make available as 'ew'. A few things are not clear to me. Basically, one can create a new comparison operator as follows. class MyComparison < AbstractComparison slug :exactend What do you exactly mean by "register your new comparison class and it's slug with DataMapper::Query::Comparison" ? Thanks for your help. Sergio On 30 July 2010 15:43, Ted Han <[email protected]> wrote: > Hey sergio, > > First things first, the symbol extensions (e.g. :thing.gte) are deprecated, > and we encourage people not to use them. My personal choice is to use the > string syntax ("name.eq" => "ted"). > > Secondly, if you pop open dm-core, all of the query comparison are classes > which can be found inside of dm-core/lib/query/conditions/comparisons.rb > > So long as you register your new comparison class and it's slug with > DataMapper::Query::Comparison, then all of DataMapper's query machinery > should automatically translate query conditions correctly, and instantiate > your conditions. > > HOWEVER, you will need to inform things like the DataMapper DataObjects > Adapter how it should transform your Comparison class into SQL if you are > using dm-do-adapter (or it's descendants). And to see about doing that you > should look at the comparison_statement method and the comparison_operator > methods in the dm-do-adapter. > > Out of curiosity what operation are you looking to add? > > -Ted > > On Fri, Jul 30, 2010 at 7:36 AM, sergio <[email protected]> wrote: > >> Hi all. >> >> I am looking for a way to introduce a new type of query operator. >> Let's imagine I have a new operator called 'op', then I'd like to be >> able to write a query as >> >> Person.all(:name.op => 'something') >> >> Any hints ? >> >> Cheers, >> >> Sergio >> >> -- >> 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]<datamapper%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/datamapper?hl=en. >> >> > -- > 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]<datamapper%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/datamapper?hl=en. > -- 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.
