[Django] #29103: sqlmigrate produces byte literal in SQL for one-off empty string default value in TextField, CharField

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #29103: sqlmigrate produces byte literal in SQL for one-off empty string default value in TextField, CharField

Django
#29103: sqlmigrate produces byte literal in SQL for one-off empty string default
value in TextField, CharField
-------------------------------------+-------------------------------------
               Reporter:  qlimax     |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:             |        Version:  2.0
  Migrations                         |       Keywords:  sqlmigrate, byte,
               Severity:  Normal     |  default value, one-off
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  1
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 {{{
 $ python manage.py makemigrations myapp
 You are trying to add a non-nullable field 'text1' to mytable without a
 default; we can't do that (the database needs something to populate
 existing rows).
 Please select a fix:
  1) Provide a one-off default now (will be set on all existing rows with a
 null value for this column)
  2) Quit, and let me add a default in models.py
 Select an option: 1
 Please enter the default value now, as valid Python
 The datetime and django.utils.timezone modules are available, so you can
 do e.g. timezone.now
 Type 'exit' to exit this prompt
 >>> ''
 Migrations for 'myapp':
   myapp/migrations/0003_somechange.py
     - Add field text1 to mytable

 Done.

 $ python manage.py sqlmigrate myapp 0003_somechange
 BEGIN;
 --
 -- Add field text1 to mytable
 --
 ALTER TABLE `myapp_mytable` ADD COLUMN `text1` longtext NOT NULL;
 UPDATE `myapp_mytable` SET `text1` = b"''";
 COMMIT;

 $ cat myapp/migrations/0003_somechange.py
 # Generated by Django 2.0.2 on 2018-02-02 11:56

 from django.db import migrations, models


 class Migration(migrations.Migration):

     dependencies = [
         ('myapp', '0002_auto_20180202_1154'),
     ]

     operations = [
         migrations.AddField(
             model_name='mytable',
             name='text1',
             field=models.TextField(default=''),
             preserve_default=False,
         ),
     ]
 $ python --version
 Python 3.4.2
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29103>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/049.cedb524213da2a53c3a3b694be4d6d29%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29103: sqlmigrate produces byte literal in SQL for one-off string default value in TextField, CharField (was: sqlmigrate produces byte literal in SQL for one-off empty string default value in TextField, CharField)

Django
#29103: sqlmigrate produces byte literal in SQL for one-off string default value in
TextField, CharField
-------------------------------------+-------------------------------------
     Reporter:  qlimax               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Migrations           |                  Version:  2.0
     Severity:  Normal               |               Resolution:
     Keywords:  sqlmigrate, byte,    |             Triage Stage:
  default value, one-off             |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/29103#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.6a1a4fa5f926922ac6420629669d04fb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29103: sqlmigrate produces byte literal in SQL for one-off string default value in TextField, CharField on MySQL (was: sqlmigrate produces byte literal in SQL for one-off string default value in TextField, CharField)

Django
In reply to this post by Django
#29103: sqlmigrate produces byte literal in SQL for one-off string default value in
TextField, CharField on MySQL
-------------------------------------+-------------------------------------
     Reporter:  Qlimax               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Migrations           |                  Version:  2.0
     Severity:  Normal               |               Resolution:
     Keywords:  sqlmigrate, byte,    |             Triage Stage:  Accepted
  default value, one-off             |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * stage:  Unreviewed => Accepted
 * easy:  1 => 0


Comment:

 This is MySQL-specific. I couldn't quickly locate where the problem is.

--
Ticket URL: <https://code.djangoproject.com/ticket/29103#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.e0e167315229ef28cf357ffbc91af25f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29103: sqlmigrate produces byte literal in SQL for one-off string default value in TextField, CharField on MySQL

Django
In reply to this post by Django
#29103: sqlmigrate produces byte literal in SQL for one-off string default value in
TextField, CharField on MySQL
-------------------------------------+-------------------------------------
     Reporter:  Qlimax               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Migrations           |                  Version:  2.0
     Severity:  Normal               |               Resolution:
     Keywords:  sqlmigrate, byte,    |             Triage Stage:  Accepted
  default value, one-off             |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/9680 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/29103#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.c22d6470d961b0602e78499dff6c4452%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29103: sqlmigrate produces byte literal in SQL for one-off string default value in TextField, CharField on MySQL

Django
In reply to this post by Django
#29103: sqlmigrate produces byte literal in SQL for one-off string default value in
TextField, CharField on MySQL
-------------------------------------+-------------------------------------
     Reporter:  Qlimax               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Migrations           |                  Version:  2.0
     Severity:  Normal               |               Resolution:
     Keywords:  sqlmigrate, byte,    |             Triage Stage:  Accepted
  default value, one-off             |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

 It's still not entirely clear to me what is the correct expected output. I
 think that internally, mysqlclient is using the `'surrogateescape'`
 encoding which is apparently not usable for some outputs like the shell.
 Any suggestion welcome.

--
Ticket URL: <https://code.djangoproject.com/ticket/29103#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.784bd53a5b834f3100107280b0f9cb7f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29103: sqlmigrate produces byte literal in SQL for one-off string default value in TextField, CharField on MySQL

Django
In reply to this post by Django
#29103: sqlmigrate produces byte literal in SQL for one-off string default value in
TextField, CharField on MySQL
-------------------------------------+-------------------------------------
     Reporter:  Qlimax               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Migrations           |                  Version:  2.0
     Severity:  Normal               |               Resolution:
     Keywords:  sqlmigrate, byte,    |             Triage Stage:  Accepted
  default value, one-off             |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

 Ah sorry, in the current use case, the expected output is simply no binary
 marker, which is fixed in my patch.
 My question is about the SQL output in the hypothetic case the default
 would be a real binary bytestring.

--
Ticket URL: <https://code.djangoproject.com/ticket/29103#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.f5f9e222cb8744d6d8c119ea8b48a85f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.