d33tah / bpgsql Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/py-bpgsql
License: GNU Lesser General Public License v2.1
Automatically exported from code.google.com/p/py-bpgsql
License: GNU Lesser General Public License v2.1
root@e3e8461d358a:/django/tests# ./runtests.py backends
Testing against Django installed in '/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django'
Creating test database for alias 'default'...
Got an error creating the test database: ERROR: database "test_postgres" already exists
Type 'yes' if you would like to try deleting the test database 'test_postgres', or 'no' to cancel: yes
Destroying old test database 'default'...
Creating test database for alias 'other'...
.EE.FFFFF...F...............F.sF.s..sE...ss.....EE.sss....F....EEEEEssssss
======================================================================
ERROR: test_cursor_contextmanager (backends.tests.BackendTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 634, in test_cursor_contextmanager
cursor.execute("select 1")
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 63, in execute
return self.cursor.execute(sql)
File "/usr/local/lib/python2.7/dist-packages/bpgsql.py", line 1347, in execute
result = self.connection._execute(cmd, args)
AttributeError: 'NoneType' object has no attribute '_execute'
======================================================================
ERROR: test_cursor_contextmanager_closing (backends.tests.BackendTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 644, in test_cursor_contextmanager_closing
self.assertTrue(cursor.closed)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 25, in __getattr__
cursor_attr = getattr(self.cursor, attr)
AttributeError: 'Cursor' object has no attribute 'closed'
======================================================================
ERROR: test_query_encoding (backends.tests.LastExecutedQueryTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 340, in test_query_encoding
cursor = data.query.get_compiler('default').execute_sql(CURSOR)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/sql/compiler.py", line 786, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/bpgsql.py", line 1347, in execute
result = self.connection._execute(cmd, args)
File "/usr/local/lib/python2.7/dist-packages/bpgsql.py", line 1030, in _execute
self.__send('Q'+cmd+'\0')
File "/usr/local/lib/python2.7/dist-packages/bpgsql.py", line 768, in __send
nSent = self.__socket.send(data)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 17-18: ordinal not in range(128)
======================================================================
ERROR: test_select_ascii_array (backends.tests.PostgreSQLTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 243, in test_select_ascii_array
b = self._select(a)
File "/django/tests/backends/tests.py", line 238, in _select
cursor.execute("SELECT %s", (val,))
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/bpgsql.py", line 1350, in execute
raise result.error
DatabaseError: ERROR: syntax error at or near "[" at character 8
======================================================================
ERROR: test_select_unicode_array (backends.tests.PostgreSQLTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 248, in test_select_unicode_array
b = self._select(a)
File "/django/tests/backends/tests.py", line 238, in _select
cursor.execute("SELECT %s", (val,))
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/bpgsql.py", line 1350, in execute
raise result.error
DatabaseError: ERROR: syntax error at or near "[" at character 8
======================================================================
ERROR: test_check_constraints (backends.tests.FkConstraintsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 779, in test_check_constraints
a.save()
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 590, in save
force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 618, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 680, in _save_table
forced_update)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 724, in _do_update
return filtered._update(values) > 0
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/query.py", line 600, in _update
return query.get_compiler(self.db).execute_sql(CURSOR)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/sql/compiler.py", line 1004, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/sql/compiler.py", line 786, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/bpgsql.py", line 1350, in execute
raise result.error
DatabaseError: ERROR: insert or update on table "backends_article" violates foreign key constraint "backends_article_reporter_id_fkey"
======================================================================
ERROR: test_disable_constraint_checks_context_manager (backends.tests.FkConstraintsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 763, in test_disable_constraint_checks_context_manager
a.save()
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 590, in save
force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 618, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 680, in _save_table
forced_update)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 724, in _do_update
return filtered._update(values) > 0
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/query.py", line 600, in _update
return query.get_compiler(self.db).execute_sql(CURSOR)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/sql/compiler.py", line 1004, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/sql/compiler.py", line 786, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/bpgsql.py", line 1350, in execute
raise result.error
DatabaseError: ERROR: insert or update on table "backends_article" violates foreign key constraint "backends_article_reporter_id_fkey"
======================================================================
ERROR: test_disable_constraint_checks_manually (backends.tests.FkConstraintsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 745, in test_disable_constraint_checks_manually
a.save()
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 590, in save
force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 618, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 680, in _save_table
forced_update)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 724, in _do_update
return filtered._update(values) > 0
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/query.py", line 600, in _update
return query.get_compiler(self.db).execute_sql(CURSOR)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/sql/compiler.py", line 1004, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/sql/compiler.py", line 786, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/bpgsql.py", line 1350, in execute
raise result.error
DatabaseError: ERROR: insert or update on table "backends_article" violates foreign key constraint "backends_article_reporter_id_fkey"
======================================================================
ERROR: test_integrity_checks_on_creation (backends.tests.FkConstraintsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 693, in test_integrity_checks_on_creation
a1.save()
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 590, in save
force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 618, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 699, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 732, in _do_insert
using=using, raw=raw)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/manager.py", line 92, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/query.py", line 921, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/sql/compiler.py", line 920, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/bpgsql.py", line 1350, in execute
raise result.error
DatabaseError: ERROR: insert or update on table "backends_article" violates foreign key constraint "backends_article_reporter_id_fkey"
======================================================================
ERROR: test_integrity_checks_on_update (backends.tests.FkConstraintsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 716, in test_integrity_checks_on_update
a1.save()
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 590, in save
force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 618, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 680, in _save_table
forced_update)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/base.py", line 724, in _do_update
return filtered._update(values) > 0
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/query.py", line 600, in _update
return query.get_compiler(self.db).execute_sql(CURSOR)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/sql/compiler.py", line 1004, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/models/sql/compiler.py", line 786, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/bpgsql.py", line 1350, in execute
raise result.error
DatabaseError: ERROR: insert or update on table "backends_article" violates foreign key constraint "backends_article_reporter_id_fkey"
======================================================================
FAIL: test_cursor_executemany (backends.tests.BackendTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 521, in test_cursor_executemany
self.assertEqual(models.Square.objects.count(), 11)
AssertionError: 12 != 11
======================================================================
FAIL: test_cursor_executemany_with_empty_params_list (backends.tests.BackendTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 530, in test_cursor_executemany_with_empty_params_list
self.assertEqual(models.Square.objects.count(), 0)
AssertionError: 12 != 0
======================================================================
FAIL: test_cursor_executemany_with_iterator (backends.tests.BackendTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 536, in test_cursor_executemany_with_iterator
self.assertEqual(models.Square.objects.count(), 5)
AssertionError: 17 != 5
======================================================================
FAIL: test_cursor_executemany_with_pyformat (backends.tests.BackendTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/test/testcases.py", line 942, in skip_wrapper
return test_func(*args, **kwargs)
File "/django/tests/backends/tests.py", line 556, in test_cursor_executemany_with_pyformat
self.assertEqual(models.Square.objects.count(), 11)
AssertionError: 28 != 11
======================================================================
FAIL: test_cursor_executemany_with_pyformat_iterator (backends.tests.BackendTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/test/testcases.py", line 942, in skip_wrapper
return test_func(*args, **kwargs)
File "/django/tests/backends/tests.py", line 565, in test_cursor_executemany_with_pyformat_iterator
self.assertEqual(models.Square.objects.count(), 5)
AssertionError: 33 != 5
======================================================================
FAIL: test_unicode_fetches (backends.tests.BackendTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 588, in test_unicode_fetches
self.assertEqual(cursor.fetchone(), ('Clark', 'Kent'))
AssertionError: [u'Clark', u'Kent'] != (u'Clark', u'Kent')
======================================================================
FAIL: test_parameter_escaping (backends.tests.EscapingChecks)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 477, in test_parameter_escaping
self.assertEqual(cursor.fetchall()[0], ('%', '%d'))
AssertionError: [u'%', u'%d'] != (u'%', u'%d')
======================================================================
FAIL: test_parameter_escaping (backends.tests.EscapingChecksDebug)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 477, in test_parameter_escaping
self.assertEqual(cursor.fetchall()[0], ('%', '%d'))
AssertionError: [u'%', u'%d'] != (u'%', u'%d')
======================================================================
FAIL: test_pass_connection_between_threads (backends.tests.ThreadTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/django/tests/backends/tests.py", line 891, in test_pass_connection_between_threads
self.assertEqual(exceptions, [])
AssertionError: Lists differ: [MultipleObjectsReturned('get(... != []
First list contains 1 additional elements.
First extra element 0:
get() returned more than one Person -- it returned 2!
- [MultipleObjectsReturned('get() returned more than one Person -- it returned 2!',)]
+ []
----------------------------------------------------------------------
Ran 74 tests in 33.185s
FAILED (failures=9, errors=10, skipped=14)
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...
What version/revision of bpgsql are you using?
2.0alpha2
Which version of Python
2.5
Which version of PostgreSQL?
8.2.3
What steps will reproduce the problem?
1.Connect to DB
2.Execute Query
The query '''SELECT dt, nachricht, nachrichtlang FROM nachrichten ORDER BY
dt DESC %s''' %limit yields the following traceback:
File "/home/karl/prozentor/prozentor-2.4/model/news.py", line 12, in
get_financial_news
cur.execute('''SELECT dt, nachricht, nachrichtlang FROM nachrichten
ORDER BY dt DESC %s''' %limit)
File "/home/karl/prozentor/prozentor-2.4/bpgsql.py", line 1343, in execute
result = self.connection._execute(cmd, args)
File "/home/karl/prozentor/prozentor-2.4/bpgsql.py", line 1028, in _execute
self.__read_response()
File "/home/karl/prozentor/prozentor-2.4/bpgsql.py", line 686, in
__read_response
getattr(self, '_pkt_' + pkt_type)()
File "/home/karl/prozentor/prozentor-2.4/bpgsql.py", line 825, in _pkt_D
self.__read_row()
File "/home/karl/prozentor/prozentor-2.4/bpgsql.py", line 721, in __read_row
row.append(result.conversion[field_num](data))
File "/home/karl/prozentor/prozentor-2.4/bpgsql.py", line 230, in
_char_to_python
return s.decode('utf-8')
File "/usr/lib/python2.5/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 24-29:
unsupported Unicode code range
Am I using the it in a wrong way, or is this a bug?
Original issue reported on code.google.com by karl42
on 3 Nov 2009 at 5:12
Just saw your most recent commit.
Is this project now dead? Are there any working pure-Python PGSQL Django backends out there?
I just fixed a bug I introduced when transitioning to Py3-compatible codebase that enabled Unicode strings to be passed with no SQL escaping. I am not the original author of this module and don't know the codebase yet - it should be checked for the possibility of an SQL injection.
02.11.2015 16:57, Barry Pederson:
The big issue with it is that it’s using version 2.0 of the pgsql
backend protocol. The current version is 3.0 introduced back in
PgSQL 7.4. (which is almost 12 years ago now). I’d imagine at some
point they’re going to want to drop support - although I haven’t seen
any actual announcements of that yet.
I'd say that we should contact PostgreSQL core devs and find out first.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.