Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. CO`--`: Wrong explanation, this has nothing to do with multiple arguments and the associativeness is wrong. Try `"%ss limit 1" % '%' % 'BOO'` to see what i mean, this expression works, whenever if we put parenthesis as you suggest, `"%ss limit 1" % ('%' % ('BOO'))` breaks/error. Also, your proposed fix is no better than the original
      singulars
    2. COI think you've misunderstood. I wasn't suggesting it had anything to do with the singularity or multiplicity of the arguments, just that if you changed from using singles to tuples it would become more clear that it's a legit thing to do. Your counter example is wrong - ('%' % ('BOO')) isn't valid. `"%s limit 1" % '%s' % 'BOO'` versus `"%s limit 1" % ('%s' % ('BOO'))`. Both work. Note that question doesn't contain the `%ss` format your example needs. That isn't a 'proposed fix' - there's nothing wrong with the original code, it's just a suggested change.
      singulars
    3. COSeems like you don't get it. (A) Putting the parenthesis the way you did changes the **order of operations**. When you have expression of the kind `A % B % C`, it is executed as `(A % B) % C`, not as `A % (B % C)`, as your first set of parens forces it to. (B) Also, your understanding that putting () around expression makes tuple out of it is wrong - it doesn't. To force tuple you either have to explicitly use constructor `tuple()`, or use a "silly comma", like so `"%s limit 1" % (sql % (table,),)` - that will create tuples but your example will still be wrong because of (A)
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload