Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notnull constraint not set on foreign key #653

Open
niphlod opened this issue Jan 26, 2015 · 1 comment
Open

notnull constraint not set on foreign key #653

niphlod opened this issue Jan 26, 2015 · 1 comment

Comments

@niphlod
Copy link
Member

niphlod commented Jan 26, 2015

From mrauch05@gmail.com on March 18, 2013 12:06:17

What steps will reproduce the problem? 1. create two tables, add a field to reference the other table and set notnull=True. e.g.
db.define_table('mytable',
Field('name', 'string'))

db.define_table('mytable2',
Field('name', 'string'),
Field('mytable', db.mytable, notnull=True)) What is the expected output? What do you see instead? the not null constraint is missing in the created db table:
CREATE TABLE mytable2
(
id serial NOT NULL,
"name" character varying(512),
mytable integer,
CONSTRAINT mytable2_pkey PRIMARY KEY (id),
CONSTRAINT mytable2_mytable_fkey FOREIGN KEY (mytable)
REFERENCES mytable (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE CASCADE
)
WITH (
OIDS=FALSE
);
ALTER TABLE mytable2 OWNER TO postgres;

instead it should be
mytable integer NOT NULL,
for the mytable column. What version of the product are you using? On what operating system? web2py 2.4.4, Windows 7, Postgres 9.0

Original issue: http://code.google.com/p/web2py/issues/detail?id=1395

@niphlod
Copy link
Member Author

niphlod commented Jan 26, 2015

From ABasta...@gmail.com on January 22, 2014 07:00:38

It appears the DAL ignores notnull, unique, and custom_qualifier for reference fields, though it is not clear why. Should probably be fixed for all three arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants