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

Support on delete cascade inline on postgres #184

Closed
jniclas opened this issue Jan 20, 2022 · 2 comments
Closed

Support on delete cascade inline on postgres #184

jniclas opened this issue Jan 20, 2022 · 2 comments

Comments

@jniclas
Copy link

jniclas commented Jan 20, 2022

Hey,

is it possible to support ON DELETE CASCADE in an inline REFERENCE statement?

--export output

-- No table exists --
2022/01/20 21:45:52 postgres: no tables found in database

Input SQL

CREATE TABLE customers (
  id UUID NOT NULL PRIMARY KEY,
  customer_name VARCHAR(255) NOT NULL
);

CREATE TABLE orders (
  id UUID NOT NULL PRIMARY KEY, 
  order_number VARCHAR(255) NOT NULL,
  customer UUID REFERENCES customers(id) ON DELETE CASCADE
);

Current output

found syntax error when parsing DDL "CREATE TABLE orders (
  id UUID NOT NULL PRIMARY KEY,
  order_number VARCHAR(255) NOT NULL,
  customer UUID REFERENCES customers(id) ON DELETE CASCADE
)": syntax error at position 147 near 'delete'

Expected output

Creates an foreignkey with on delete cascade.

Best reagrds
Niclas

@k0kubun
Copy link
Collaborator

k0kubun commented Jan 21, 2022

I ran out of today's time for #183, so I didn't get to fix this today. Sorry.

Out of curiosity, how many other things do you think are missing in psqldef for your use case? I'd appreciate it if you can file all you need at once instead of gradually filing a few every day.

@jniclas
Copy link
Author

jniclas commented Jan 21, 2022

Hello,
no problem, I'm glad you're fixing the problems so quickly.

I am testing out how well the combination of psqldef and graphjin, both as go library work together.
What I still have to test is full-text search, where I need a tsvector type column: https://github.com/dosco/graphjin/wiki/Detailed-Start#full-text-search

CREATE TABLE ... (
...
tsv tsvector GENERATED ALWAYS AS (to_tsvector('english', name) || to_tsvector('english',description)) STORED,
...);
CREATE INDEX index_products_on_tsv ON products USING GIN (tsv tsvector_ops);

and autocomplete, where the column needs an expression "text_pattern_ops" https://github.com/dosco/graphjin/wiki/Detailed-Start#autocomplete

CREATE INDEX product_name_autocomplete_index ON products(name text_pattern_ops);

Apart from that, I haven't seen anything else that I need for it.
So far the libraries complement each other perfectly. Many thanks for the development of sqldef.

Best regards
Niclas

k0kubun added a commit that referenced this issue Jan 23, 2022
k0kubun added a commit that referenced this issue Jan 23, 2022
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

No branches or pull requests

2 participants