Re: [Django] #23415: OneToField reference to default 'id' instead of actual primary key

2014-09-25 Thread Django
#23415: OneToField reference to default 'id' instead of actual primary key
-+---
 Reporter:  sky-chen |Owner:  Markush2010
 Type:  Bug  |   Status:  closed
Component:  Migrations   |  Version:  1.7
 Severity:  Release blocker  |   Resolution:  fixed
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+---

Comment (by Tim Graham ):

 In [changeset:"00c2a721e20f6487571ed14b69aed620f474104c"]:
 {{{
 #!CommitTicketReference repository=""
 revision="00c2a721e20f6487571ed14b69aed620f474104c"
 [1.7.x] Fixed #23415 -- Added fields for unmanaged and proxy model
 migrations.

 Thanks sky-chen for the report.

 Backport of 215aa4f53b from master
 }}}

--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.7982a93a4aeecf3e6d3b865532e10fa2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23415: OneToField reference to default 'id' instead of actual primary key

2014-09-25 Thread Django
#23415: OneToField reference to default 'id' instead of actual primary key
-+---
 Reporter:  sky-chen |Owner:  Markush2010
 Type:  Bug  |   Status:  closed
Component:  Migrations   |  Version:  1.7
 Severity:  Release blocker  |   Resolution:  fixed
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+---
Changes (by Tim Graham ):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"215aa4f53b6bbd07d5c1eecfa94e7fcd00da813e"]:
 {{{
 #!CommitTicketReference repository=""
 revision="215aa4f53b6bbd07d5c1eecfa94e7fcd00da813e"
 Fixed #23415 -- Added fields for unmanaged and proxy model migrations.

 Thanks sky-chen for the report.
 }}}

--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.fdc13fc4fcb08487e75d979d22e1d547%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23415: OneToField reference to default 'id' instead of actual primary key

2014-09-24 Thread Django
#23415: OneToField reference to default 'id' instead of actual primary key
-+---
 Reporter:  sky-chen |Owner:  Markush2010
 Type:  Bug  |   Status:  assigned
Component:  Migrations   |  Version:  1.7
 Severity:  Release blocker  |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+---
Changes (by timgraham):

 * severity:  Normal => Release blocker


--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.e9f6bc99156fe803cecfda6896eca12c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23415: OneToField reference to default 'id' instead of actual primary key

2014-09-07 Thread Django
#23415: OneToField reference to default 'id' instead of actual primary key
+---
 Reporter:  sky-chen|Owner:  Markush2010
 Type:  Bug |   Status:  assigned
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Accepted
Has patch:  1   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+---
Changes (by Markush2010):

 * has_patch:  0 => 1


Comment:

 I added a pull-request: https://github.com/django/django/pull/3193

--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.e5c661006ee94b8026724c7d0d58a0fc%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23415: OneToField reference to default 'id' instead of actual primary key

2014-09-05 Thread Django
#23415: OneToField reference to default 'id' instead of actual primary key
+---
 Reporter:  sky-chen|Owner:  Markush2010
 Type:  Bug |   Status:  assigned
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Accepted
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+---
Changes (by Markush2010):

 * owner:  nobody => Markush2010
 * status:  new => assigned


--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.3df7627b8b345386702ca71b70e9f3c7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23415: OneToField reference to default 'id' instead of actual primary key

2014-09-04 Thread Django
#23415: OneToField reference to default 'id' instead of actual primary key
+
 Reporter:  sky-chen|Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Accepted
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+
Description changed by sky-chen:

Old description:

> == Reproduce ==
> 1. create a new project 'bug'
> 2. create two app 'deg', 'pubsite'
> 3. create models:
>
> {{{
> # bug/deg/models.py
> from django.db import models
>
> # Clients
> class Client(models.Model):
> client_id = models.IntegerField('ID', primary_key=True)
> name = models.CharField('Name', max_length=255)
> short_name = models.CharField('Short name', max_length=35)
>
> class Meta:
> managed = False
> db_table = 'Clients'
> verbose_name = 'Client'
>

> # bug/pubsite/models.py
> from django.db import models
> from django.contrib.auth.models import User
> from deg.models import Client
>
> class Account(models.Model):
> '''
> Represents a general tranzsoft account,
> which can be client of any associated departments
> '''
> user= models.OneToOneField(User)
> deg_client  = models.OneToOneField(Client)
> }}}
>
> 4. make migrations
> 5. check sqlmigrate pubsite 0001
>
> {{{
> BEGIN;
>
> CREATE TABLE `pubsite_account` (`id` integer AUTO_INCREMENT NOT NULL
> PRIMARY KEY, `deg_client_id` integer NOT NULL UNIQUE, `user_id` integer
> NOT NULL UNIQUE);
> ALTER TABLE `pubsite_account` ADD CONSTRAINT
> pubsite_account_deg_client_id_1b7724045f4a7977_fk_Clients_id FOREIGN KEY
> (`deg_client_id`) REFERENCES `Clients` (`id`);
> ALTER TABLE `pubsite_account` ADD CONSTRAINT
> pubsite_account_user_id_3d5e7937e7fad36_fk_auth_user_id FOREIGN KEY
> (`user_id`) REFERENCES `auth_user` (`id`);
>
> COMMIT;
> }}}

New description:

 == Reproduce ==
 1. create a new project 'bug'
 2. create two app 'deg', 'pubsite'
 3. create models:

 {{{
 # bug/deg/models.py
 from django.db import models

 # Clients
 class Client(models.Model):
 client_id = models.IntegerField('ID', primary_key=True)
 name = models.CharField('Name', max_length=255)
 short_name = models.CharField('Short name', max_length=35)

 class Meta:
 managed = False
 db_table = 'Clients'
 verbose_name = 'Client'


 # bug/pubsite/models.py
 from django.db import models
 from django.contrib.auth.models import User
 from deg.models import Client

 class Account(models.Model):
 user= models.OneToOneField(User)
 deg_client  = models.OneToOneField(Client)
 }}}

 4. make migrations
 5. check sqlmigrate pubsite 0001

 {{{
 BEGIN;

 CREATE TABLE `pubsite_account` (`id` integer AUTO_INCREMENT NOT NULL
 PRIMARY KEY, `deg_client_id` integer NOT NULL UNIQUE, `user_id` integer
 NOT NULL UNIQUE);
 ALTER TABLE `pubsite_account` ADD CONSTRAINT
 pubsite_account_deg_client_id_1b7724045f4a7977_fk_Clients_id FOREIGN KEY
 (`deg_client_id`) REFERENCES `Clients` (`id`);
 ALTER TABLE `pubsite_account` ADD CONSTRAINT
 pubsite_account_user_id_3d5e7937e7fad36_fk_auth_user_id FOREIGN KEY
 (`user_id`) REFERENCES `auth_user` (`id`);

 COMMIT;
 }}}

--

--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.20cfa892e3dbe81af1e473c356027c0d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23415: OneToField reference to default 'id' instead of actual primary key

2014-09-04 Thread Django
#23415: OneToField reference to default 'id' instead of actual primary key
+
 Reporter:  sky-chen|Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  1.7
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Accepted
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+
Changes (by Markush2010):

 * cc: Markush2010 (added)
 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0
 * type:  Uncategorized => Bug
 * stage:  Unreviewed => Accepted


Comment:

 Some details that are causing the problem: The migration `0001` for
 `deg.Client` has a `CreateModel` operation that adds the Client model to
 Django's migration state. Unfortunately the operation doesn't contain any
 fields:

 {{{#!python
 migrations.CreateModel(
 name='Client',
 fields=[],
 options={
 'managed': False,
 'db_table': 'Clients',
 'verbose_name': 'Client',
 },
 bases=(models.Model,),
 ),
 }}}

 Therefore Django doesn't know about the explicit primary key field and
 cannot point the FK their but rather relies on some defaults. The problem
 is in
 
`django.db.migrations.autodetector.MigrationAutodetector.generate_created_unmanaged()`
 and `.generate_created_proxies()` and which makes proxy models also be
 affected by that bug.

 Right now this problem can be worked around with the following steps:

 1. remove existing migrations for `dep` and `pubsite`
 2. change `managed = False` to `managed = True`
 3. run `manage.py makemigrations dep pubsite`
 4. change `managed = True` back to `managed = False`
 5. in `dep.migrations.0001_initial` add `'managed': False` as a new option
 to the `options` argument of the `CreateModel` operation.

--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.ef748649959c5922b0f43c1f4da7ace8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #23415: OneToField reference to default 'id' instead of actual primary key

2014-09-04 Thread Django
#23415: OneToField reference to default 'id' instead of actual primary key
---+
 Reporter:  sky-chen   |  Owner:  nobody
 Type:  Uncategorized  | Status:  new
Component:  Migrations |Version:  1.7
 Severity:  Normal |   Keywords:
 Triage Stage:  Unreviewed |  Has patch:  0
Easy pickings:  0  |  UI/UX:  0
---+
 == Reproduce ==
 1. create a new project 'bug'
 2. create two app 'deg', 'pubsite'
 3. create models:

 {{{
 # bug/deg/models.py
 from django.db import models

 # Clients
 class Client(models.Model):
 client_id = models.IntegerField('ID', primary_key=True)
 name = models.CharField('Name', max_length=255)
 short_name = models.CharField('Short name', max_length=35)

 class Meta:
 managed = False
 db_table = 'Clients'
 verbose_name = 'Client'


 # bug/pubsite/models.py
 from django.db import models
 from django.contrib.auth.models import User
 from deg.models import Client

 class Account(models.Model):
 '''
 Represents a general tranzsoft account,
 which can be client of any associated departments
 '''
 user= models.OneToOneField(User)
 deg_client  = models.OneToOneField(Client)
 }}}

 4. make migrations
 5. check sqlmigrate pubsite 0001

 {{{
 BEGIN;

 CREATE TABLE `pubsite_account` (`id` integer AUTO_INCREMENT NOT NULL
 PRIMARY KEY, `deg_client_id` integer NOT NULL UNIQUE, `user_id` integer
 NOT NULL UNIQUE);
 ALTER TABLE `pubsite_account` ADD CONSTRAINT
 pubsite_account_deg_client_id_1b7724045f4a7977_fk_Clients_id FOREIGN KEY
 (`deg_client_id`) REFERENCES `Clients` (`id`);
 ALTER TABLE `pubsite_account` ADD CONSTRAINT
 pubsite_account_user_id_3d5e7937e7fad36_fk_auth_user_id FOREIGN KEY
 (`user_id`) REFERENCES `auth_user` (`id`);

 COMMIT;
 }}}

--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.f3746786e5a3661c31aa4f351a765f01%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.