Skip to content

ColNamesTests.test_CheckCaseInConverterName fails #16

Open
@zmedico

Description

I'm having difficulty trying to make test_CheckCaseInConverterName and test_CheckColName both succeed simultaneously (though they both succeed with python's own sqlite3 module).

=================================== FAILURES ===================================
_________________ ColNamesTests.test_CheckCaseInConverterName __________________

self = <test_types.ColNamesTests testMethod=test_CheckCaseInConverterName>

    def test_CheckCaseInConverterName(self):
>       self.cur.execute("select 'other' as \"x [b1b1]\"")

src/test/test_types.py:298: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/pyrqlite/cursors.py:178: in execute
    else converter(value))))
src/pyrqlite/extensions.py:180: in _decode_base64_converter
    return converter(value.decode('base64'))
/usr/lib64/python2.7/encodings/base64_codec.py:42: in base64_decode
    output = base64.decodestring(input)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

s = 'other'

    def decodestring(s):
        """Decode a string."""
>       return binascii.a2b_base64(s)
E       Error: Incorrect padding

As you can see, it fails because it's trying to decode 'other' as base64. The sql which does not need base64 decoding is as follows:

create table test(x foo);
select 'other' as "x [b1b1]";

Meanwhile, test_CheckColName would fail without the base64 decoding support. The sql that triggers the need for base64 decoding is as follows:

create table test(x foo);
insert into test(x) values ('xxx');
select x as "x [bar]" from test;

Feeding the sql statements into the rqlite v3.14.0 command confirms, where 'eHh4' is the base64 encoding of 'xxx':

127.0.0.1:4001> create table test(x foo);
1 row affected (0.000543 sec)
127.0.0.1:4001> select 'other' as "x [b1b1]";
+----------+
| x [b1b1] |
+----------+
| other    |
+----------+
127.0.0.1:4001> insert into test(x) values ('xxx');
1 row affected (0.000206 sec)
127.0.0.1:4001> select x as "x [bar]" from test;
+---------+
| x [bar] |
+---------+
| eHh4    |
+---------+
127.0.0.1:4001>

I see that rqlite/rqlite#265 reports the issue for rqlited, and the relevant code is visible in rqlite/rqlite#244.

@alanjds

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions