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

Wrong reference generation / PRAGMA foreign_keys not set #32

Merged
merged 2 commits into from
Apr 11, 2013

Conversation

vonloxley
Copy link
Contributor

PRAGMA foreign_keys=ON needs to be set every time the database is opened.

References are targeted at their own table, not at the referenced table.

public class Dough extends Model {
    @Column(name = "name", notNull=true, unique=true)
    public String name;
[…]
@Table(name = "Ingredient")
public class Ingredient extends Model {
    @Column(name = "name", notNull=true)
    public String name;

    @Column(name = "dough")
    public Dough dough;

should be

CREATE TABLE Ingredient (
    Id INTEGER PRIMARY KEY AUTOINCREMENT
    , name TEXT NOT NULL ON CONFLICT FAIL
    , dough INTEGER REFERENCES Dough(Id) ON DELETE NO ACTION ON UPDATE NO ACTION);

but

CREATE TABLE Ingredient (
    Id INTEGER PRIMARY KEY AUTOINCREMENT
    , name TEXT NOT NULL ON CONFLICT FAIL
    , dough INTEGER REFERENCES Ingredient(Id) ON DELETE NO ACTION ON UPDATE NO ACTION);

is generated.

This was referenced Jan 21, 2013
pardom-zz pushed a commit that referenced this pull request Apr 11, 2013
Wrong reference generation / PRAGMA foreign_keys not set
@pardom-zz pardom-zz merged commit df9fb5b into pardom-zz:master Apr 11, 2013
@vonloxley vonloxley deleted the reference_correct_table branch April 11, 2013 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants