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

[psqldef] 「::(cast)」 statement is converted to 「collate」statement in second migration #278

Closed
you8-hz opened this issue Aug 26, 2022 · 2 comments

Comments

@you8-hz
Copy link

you8-hz commented Aug 26, 2022

First migration is successful but second migration failed.
「::(cast)」 statement is converted to 「collate」statement in second migration.
Please confirm this error.

$ psqldef --version
v0.13.7

--export output

CREATE TABLE "public"."hoge" (
    "amount" text
);

CREATE VIEW public.hoge_view AS SELECT (hoge.amount)::numeric(10,2) AS amount_num FROM hoge;

Input SQL

create table hoge (
    amount   text
);

create view hoge_view as
select
    amount::numeric(10,2) as amount_num
from hoge;

Current output

CREATE OR REPLACE VIEW "public"."hoge_view" AS select amount collate  as amount_num from hoge;
2022/08/26 19:26:57 pq: syntax error at or near "as"

Expected output

No errors.

@you8-hz you8-hz changed the title [psqldef] 「cast(::)」 statement is converted to 「collate」statement in second migration [psqldef] 「::(cast)」 statement is converted to 「collate」statement in second migration Aug 26, 2022
@k0kubun
Copy link
Collaborator

k0kubun commented Aug 26, 2022

Thanks for reporting it. Now that we have the original PostgreSQL parser #241, which is currently just partially applied, I think this one is much easier to fix than before. However, as I need to focus on conference preparations for a few weeks, please allow me to have a look at this after Sep 10th or so. I could also look at a pull request if filed.

@k0kubun
Copy link
Collaborator

k0kubun commented Sep 28, 2022

Fixed in v0.13.10.

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