Just do a string substitution. GQL isn't SQL and you're not at risk of an injection attack.
On Thu, Sep 16, 2010 at 11:26 PM, Martin Webb <[email protected]> wrote: > Tim. Yes that was my first guess - i thought max was coming in as None - > but that isnt the case? The code below fails?? > > BadQueryError: Parse Error: Non-number limit in LIMIT clause at symbol :2 > > > def load_all(stream,max=10): > test=10 > indexes = db.GqlQuery("SELECT __key__ FROM message_index WHERE > receivers = :1 ORDER BY created DESC LIMIT :2", stream,test) > > > > > Regards > > > > > > *Martin Webb* > > The information contained in this email is confidential and may contain > proprietary information. It is meant solely for the intended recipient. > Access to this email by anyone else is unauthorised. If you are not the > intended recipient, any disclosure, copying, distribution or any action > taken or omitted in reliance on this, is prohibited and may be unlawful. No > liability or responsibility is accepted if information or data is, for > whatever reason corrupted or does not reach its intended recipient. No > warranty is given that this email is free of viruses. The views expressed in > this email are, unless otherwise stated, those of the author > > > > > > > ------------------------------ > *From:* Tim Hoffman <[email protected]> > *To:* Google App Engine <[email protected]> > *Sent:* Fri, 17 September, 2010 4:36:14 > *Subject:* [google-appengine] Re: gqlquery passing in numeric parameters - > help needed > > Hi > > Have you confirmed max is an int and not a string. My bet that is the > problem. > > Alternately use > > results = message_index.all(keys_only=True).filter('receivers = > ',stream).order('-created').fetch(max) > > But max will still need to be an int ;-) > > T > > > On Sep 17, 10:03 am, Martin Webb <[email protected]> wrote: > > Can someone tell me how i pass the max parameter into the query below. > Ive tried > > : > > ("SELECT __key__ FROM message_index WHERE receivers = :1 ORDER BY created > DESC > > LIMIT :2", stream,max) > > but it throws an erorr: Non-number limit in LIMIT clause > > > > It works fine as below - but i need to pass the max param in > > > > def load_all(stream,max=10): > > indexes = db.GqlQuery("SELECT __key__ FROM message_index WHERE > receivers = > > :1 ORDER BY created DESC LIMIT 10", stream) > > > > Regards > > > > Martin Webb > > > > The information contained in this email is confidential and may contain > > proprietary information. It is meant solely for the intended recipient. > Access > > to this email by anyone else is unauthorised. If you are not the intended > > recipient, any disclosure, copying, distribution or any action taken or > omitted > > in reliance on this, is prohibited and may be unlawful. No liability or > > responsibility is accepted if information or data is, for whatever reason > > corrupted or does not reach its intended recipient. No warranty is given > that > > this email is free of viruses. The views expressed in this email are, > unless > > otherwise stated, those of the author > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to google-appengine+ > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-appengine?hl=en. > > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-appengine%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-appengine?hl=en. > -- You received this message because you are subscribed to the Google Groups "Google App Engine" 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/google-appengine?hl=en.
