Re: [Django] #35163: sqlite3.OperationalError: no such column: django_migrations.id

2024-02-04 Thread Django
#35163: sqlite3.OperationalError: no such column: django_migrations.id
-+-
 Reporter:  milahu   |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  5.0
  (models, ORM)  |   Resolution:
 Severity:  Normal   |  worksforme
 Keywords:  sqlite   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by Simon Charette):

 As mentioned previously by a few contributors already, **this issue
 tracker is not a support channel** so you won't get answers to you
 questions.

 If you are trying to stitch together code to work around a known
 limitation of the framework with
 [https://code.djangoproject.com/ticket/32577 regards to its lack of
 support for auto-generated UUID] then you are likely to run into issues
 otherwise the ticket would have likely already be resolved.
-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d7512caf1-0a86-9f77-4d2c-a741-dd2a0ad5f995-00%40eu-central-1.amazonses.com.


Re: [Django] #35163: sqlite3.OperationalError: no such column: django_migrations.id

2024-02-04 Thread Django
#35163: sqlite3.OperationalError: no such column: django_migrations.id
-+-
 Reporter:  milahu   |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  5.0
  (models, ORM)  |   Resolution:
 Severity:  Normal   |  worksforme
 Keywords:  sqlite   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by milahu):

 the "id" columns are missing in the "CREATE TABLE" queries, but later
 appear in "INSERT INTO" queries

 currently im trying to trace the "CREATE TABLE" queries, but these queries
 are not passed through

 django/db/backends/sqlite3/base.py

 {{{
 class SQLiteCursorWrapper(Database.Cursor):
 def executescript(self, query):
 print(f"django/db/backends/sqlite3/base.py executescript
 query={repr(query)}")
 return super().executescript(query)
 def execute(self, query, params=None):
 # ...
 print(f"django/db/backends/sqlite3/base.py execute
 query={repr(query)} params={repr(params)}")
 return super().execute(query, params)
 def executemany(self, query, param_list):
 # ...
 print(f"django/db/backends/sqlite3/base.py executemany
 query={repr(query)} param_list={repr(param_list)}")
 return super().executemany(query, param_list)
 }}}

 the first query i see is

 {{{
 CREATE UNIQUE INDEX "django_content_type_app_label_model_76bd3d3b_uniq" ON
 "django_content_type" ("app_label", "model")
 }}}

 but before that query i already have the schema

 {{{
 CREATE TABLE "django_migrations" ("id" integer NOT NULL PRIMARY KEY
 AUTOINCREMENT, "app" varchar(255) NOT NULL, "name" varchar(255) NOT NULL,
 "applied" da
 tetime NOT NULL)
 CREATE TABLE sqlite_sequence(name,seq)
 CREATE TABLE "django_content_type" ("id" integer NOT NULL PRIMARY KEY
 AUTOINCREMENT, "name" varchar(100) NOT NULL, "app_label" varchar(100) NOT
 NULL, "mod
 }}}

 as reported by

 {{{
 if True:
 print("schema:")
 for name, sql in super().execute("SELECT name, sql FROM
 sqlite_schema"):
 for line in sql.split("\n"):
 print("  " + line)
 }}}

 ideas...?

 im using the sqlite backend

 i would expect that all queries are passed through SQLiteCursorWrapper
-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d736842a3-2d4ecade-1b0d-4bf1-adfa-591c3e02fa9c-00%40eu-central-1.amazonses.com.


Re: [Django] #35163: sqlite3.OperationalError: no such column: django_migrations.id

2024-02-03 Thread Django
#35163: sqlite3.OperationalError: no such column: django_migrations.id
-+-
 Reporter:  milahu   |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  5.0
  (models, ORM)  |   Resolution:
 Severity:  Normal   |  worksforme
 Keywords:  sqlite   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by milahu):

 > to reproduce, build ​https://github.com/milahu/archivebox/tree/django4
 with django 4.2.9 and run

 the "no such column: id" error seems to be caused by

 
https://github.com/milahu/archivebox/commit/2e9a1f473ed0abaa9618d6ed6f55aa9202d7acbb

 based on https://code.djangoproject.com/ticket/32577

 {{{
 DEFAULT_AUTO_FIELD = 'django.db.models.UUIDAutoField'
 }}}

 {{{
 class UUIDAutoField(models.fields.AutoField, models.fields.UUIDField):

 def __init__(self, *args, **kwargs):
 #kwargs['db_default'] = RandomUUID()
 #kwargs['db_default'] = uuid.uuid4()
 super().__init__(*args, **kwargs)

 def deconstruct(self):
 name, path, args, kwargs = super().deconstruct()
 #del kwargs['db_default']
 return name, path, args, kwargs

 def get_internal_type(self):
 return 'UUIDAutoField'

 def rel_db_type(self, connection):
 return models.fields.UUIDField().db_type(connection=connection)

 models.UUIDAutoField = UUIDAutoField
 }}}

 because later, i get the same "no such column: id" error, when django is
 trying to migrate this SQL table

 {{{
 class Snapshot(models.Model):

 # FIXME sqlite3.OperationalError: table new__core_snapshot has no
 column named id
 id = models.UUIDAutoField(primary_key=True, default=uuid.uuid4,
 editable=False)
 }}}
-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d71227dee-93fd466c-8c15-49a0-b4b9-c9ea36ab478f-00%40eu-central-1.amazonses.com.


Re: [Django] #35163: sqlite3.OperationalError: no such column: django_migrations.id

2024-02-03 Thread Django
#35163: sqlite3.OperationalError: no such column: django_migrations.id
-+-
 Reporter:  milahu   |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  5.0
  (models, ORM)  |   Resolution:
 Severity:  Normal   |  worksforme
 Keywords:  sqlite   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by Tim Graham):

 I think we need a more minimal example. Perhaps if you try to put one
 together you'll find the cause of the issue.
-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d711d8c26-db69c8f4-ba5d-4145-8b32-263a4b6d1328-00%40eu-central-1.amazonses.com.


Re: [Django] #35163: sqlite3.OperationalError: no such column: django_migrations.id

2024-02-03 Thread Django
#35163: sqlite3.OperationalError: no such column: django_migrations.id
-+-
 Reporter:  milahu   |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  5.0
  (models, ORM)  |   Resolution:
 Severity:  Normal   |  worksforme
 Keywords:  sqlite   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by milahu):

 to reproduce, build https://github.com/milahu/archivebox/tree/django4 with
 django 4.2.9 and run

 {{{
 $ archivebox init
 $ sqlite3 index.sqlite3 .schema
 CREATE TABLE IF NOT EXISTS "django_migrations" ("app" varchar(255) NOT
 NULL, "name" varchar(255) NOT NULL, "applied" datetime NOT NULL);
 }}}

 expected: there should be an "id" column in the "django_migrations" table
-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d70c17963-63c2372b-b549-4bbc-a184-21221ba0ceb2-00%40eu-central-1.amazonses.com.


Re: [Django] #35163: sqlite3.OperationalError: no such column: django_migrations.id

2024-02-03 Thread Django
#35163: sqlite3.OperationalError: no such column: django_migrations.id
-+-
 Reporter:  milahu   |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  5.0
  (models, ORM)  |   Resolution:
 Severity:  Normal   |  worksforme
 Keywords:  sqlite   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * status:  new => closed
 * resolution:   => worksforme

Comment:

 Implicit `id` is added automatically to all models. I don't think you've
 explained the issue in enough detail to confirm a bug in Django. Please
 reopen the ticket if you can debug your issue and provide details about
 why and where Django is at fault. If you're having trouble understanding
 how Django works, see TicketClosingReasons/UseSupportChannels for ways to
 get help.
-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d70248b42-2bf57268-315a-4459-8262-4da670e5fcf6-00%40eu-central-1.amazonses.com.


[Django] #35163: sqlite3.OperationalError: no such column: django_migrations.id

2024-02-03 Thread Django
#35163: sqlite3.OperationalError: no such column: django_migrations.id
-+-
   Reporter:  milahu |  Owner:  nobody
   Type:  Bug| Status:  new
  Component:  Database   |Version:  5.0
  layer (models, ORM)|
   Severity:  Normal |   Keywords:  sqlite
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 continue https://github.com/django/django/pull/17815

 the error is caused by a django app, trying to record an applied database
 migration
 django/db/migrations/executor.py

 workaround: add the "id" column explicitly to class Migration

 django/db/migrations/recorder.py

 {{{
 class Migration(models.Model):
 id = models.IntegerField(primary_key=True)
 app = models.CharField(max_length=255)
 name = models.CharField(max_length=255)
 applied = models.DateTimeField(default=now)
 }}}

 https://github.com/django/django/pull/17815#issuecomment-1925345512

 > Implicit id is added automatically to all models

 but that is not reflected in the sqlite schema: there is no "id" column

 so maybe this is a bug in the sqlite backend
-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018d701b0140-c4aa76d7-bd5a-4aa6-99be-685a7ef81a02-00%40eu-central-1.amazonses.com.