cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Blake Visin (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-2993) Issues with parameters being escaped correctly in Python CQL
Date Mon, 08 Aug 2011 23:18:27 GMT

    [ https://issues.apache.org/jira/browse/CASSANDRA-2993?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13081291#comment-13081291
] 

Blake Visin commented on CASSANDRA-2993:
----------------------------------------

Try:

{code}
cql = 'UPDATE sites SET :col = :val WHERE KEY = :site_id'

vals = {'col': 'feed_stats:1312493736688033024',
 'site_id': '29ffb9d2-c205-11e0-a2a2-001fe14cba06',
 'val': "(dp0\nS'1'\np1\n(lp2\nI1\naI2\naI3\naI4\nasS'0'\np3\n(lp4\nI1\naI2\naI3\naI4\nasS'3'\np5\n(lp6\nI1\naI2\naI3\naI4\nasS'2'\np7\n(lp8\nI1\naI2\naI3\naI4\nas."}

cursor = cql.connect('cf')
cursor.execute(cql, vals)
{code}

My Result (after patching with Tyler's pycql.txt, but not with cql-grammar.txt)
I am printing out the prepared query
{code}
USE totalporn;
UPDATE sites SET 'feed_stats:1312493736688033024' = '(dp0
S''1''
p1
(lp2
I1
aI2
aI3
aI4
asS''0''
p3
(lp4
I1
aI2
aI3
aI4
asS''3''
p5
(lp6
I1
aI2
aI3
aI4
asS''2''
p7
(lp8
I1
aI2
aI3
aI4
as.' WHERE KEY = '29ffb9d2-c205-11e0-a2a2-001fe14cba06'
Traceback (most recent call last):
  File "/home/blake/test.py", line 10, in <module>
    cursor.execute(sql, vals)
  File "/usr/local/lib/python2.7/dist-packages/cql/cursor.py", line 135, in execute
    raise cql.ProgrammingError("Bad Request: %s" % ire.why)
cql.ProgrammingError: Bad Request: line 30:3 mismatched character ''' expecting '.'
{code}


The string comes from a pickle'd dict contaning strings as keys and a list as values:

{code}

import pickle

vals = {'col': 'feed_stats:1312493736688033024',
 'site_id': '29ffb9d2-c205-11e0-a2a2-001fe14cba06',
 'val': "(dp0\nS'1'\np1\n(lp2\nI1\naI2\naI3\naI4\nasS'0'\np3\n(lp4\nI1\naI2\naI3\naI4\nasS'3'\np5\n(lp6\nI1\naI2\naI3\naI4\nasS'2'\np7\n(lp8\nI1\naI2\naI3\naI4\nas."}

print pickle.loads((vals['val']))

{code}
returns
{code}
{'1': [1, 2, 3, 4], '0': [1, 2, 3, 4], '3': [1, 2, 3, 4], '2': [1, 2, 3, 4]}
{code}




> Issues with parameters being escaped correctly in Python CQL
> ------------------------------------------------------------
>
>                 Key: CASSANDRA-2993
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-2993
>             Project: Cassandra
>          Issue Type: Bug
>         Environment: Python CQL
>            Reporter: Blake Visin
>            Assignee: Tyler Hobbs
>              Labels: CQL, parameter, python
>         Attachments: 2993-cql-grammar.txt, 2993-pycql.txt, 2993-system-test.txt
>
>
> When using parameterised queries in Python CQL strings are not being escaped correctly.
> Query and Parameters:
> {code}
> 'UPDATE sites SET :col = :val WHERE KEY = :site_id'
> {'col': 'feed_stats:1312493736688033024',
>  'site_id': '899d15e8-bd4a-11e0-bc8c-001fe14cba06',
>  'val': "(dp0\nS'1'\np1\n(lp2\nI1\naI2\naI3\naI4\nasS'0'\np3\n(lp4\nI1\naI2\naI3\naI4\nasS'3'\np5\n(lp6\nI1\naI2\naI3\naI4\nasS'2'\np7\n(lp8\nI1\naI2\naI3\naI4\nas."}
> {code}
> Query trying to be executed after processing parameters
> {code}     
> "UPDATE sites SET 'feed_stats:1312493736688033024' = '(dp0\nS''1''\np1\n(lp2\nI1\naI2\naI3\naI4\nasS''0''\np3\n(lp4\nI1\naI2\naI3\naI4\nasS''3''\np5\n(lp6\nI1\naI2\naI3\naI4\nasS''2''\np7\n(lp8\nI1\naI2\naI3\naI4\nas.'
WHERE KEY = '899d15e8-bd4a-11e0-bc8c-001fe14cba06'"
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message