Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#22626 closed Bug (fixed)

SQLite's DatabaseSchemaEditor.quote_value trips on buffer and memoryview instances

Reported by: loic84 Owned by: Raphaël Barrois
Component: Database layer (models, ORM) Version: 1.7-beta-2
Severity: Release blocker Keywords:
Cc: Andrew Godwin Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Since e9a456d11b5b63389b466ed435ef3915f0e79e4c default values for migrations go through get_db_prep_save() which in case of BinaryField results in buffer (PY2) or memoryview (PY3) instances. This causes a ValueError since quote_value() doesn't specifically support these types: https://github.com/django/django/blob/master/django/db/backends/sqlite3/schema.py#L32.

The test case for #22424 (https://github.com/django/django/pull/2634) demonstrates the issue.

Dunno if it's relevant but the Oracle backend falls back to str rather than raising an exception: https://github.com/django/django/blob/master/django/db/backends/oracle/schema.py#L28

Change History (7)

comment:1 by Tim Graham, 10 years ago

Triage Stage: UnreviewedAccepted
Version: master1.7-beta-2

comment:2 by Raphaël Barrois, 10 years ago

Owner: changed from nobody to Raphaël Barrois
Status: newassigned

comment:3 by Raphaël Barrois, 10 years ago

Has patch: set

A full patch including test has been added at https://github.com/django/django/pull/2670 (pull request against stable/1.7.x).

This patch also fixes a slight issue in the SQLite backend when re-making a table: default values for new fields where incorrectly quoted with "column name" quoting rules.

comment:4 by Raphaël Barrois, 10 years ago

Triage Stage: AcceptedReady for checkin

I've updated the patch, which has been reviewed by shai.

Marking "Ready for Checkin" with his benediction.

comment:5 by loic84, 10 years ago

I've added this commit to the PR for #22424: https://github.com/django/django/pull/2634.

comment:6 by Loic Bistuer <loic.bistuer@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In 6aacb4c9915c83a897dbde0b11cc46131fc7d16e:

Fixed #22626 -- Allow BinaryField defaults with SQlite.

Also fixes a slight issue in sqlite3.schema._remake_table where
default values where quoted with "column name" quoting rules.

Reference for quoting: http://www.sqlite.org/lang_expr.html

Thanks Shai Berger for the review. Refs #22424.

comment:7 by Tim Graham <timograham@…>, 10 years ago

In 1a29675d76de00d6fad9b366fc66e8b6d541c3b6:

[1.7.x] Fixed #22626 -- Allow BinaryField defaults with SQlite.

Also fixes a slight issue in sqlite3.schema._remake_table where
default values where quoted with "column name" quoting rules.

Reference for quoting: http://www.sqlite.org/lang_expr.html

Thanks Shai Berger for the review. Refs #22424.

Backport of 6aacb4c991 from master

Note: See TracTickets for help on using tickets.
Back to Top