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

SELECT INSERTで JOINすると、ON CONFLICT句のインデントが不正になる #18

Open
ma91n opened this issue Sep 20, 2022 · 0 comments
Labels

Comments

@ma91n
Copy link
Contributor

ma91n commented Sep 20, 2022

Version

$ usqlfmt --version
usqlfmt 0.1.4

As Is

INSERT
INTO
	distributors
(
	did
,	dname
)
SELECT
	did
,	dname
FROM
	my_distributors	md
INNER JOIN
	company	cp
ON
	md.company_cd	=	cp.company_cd
AND	cp.delete_flg	=	FALSE	ON	CONFLICT	ON	CONSTRAINT	distributors_pkey	DO
UPDATE
SET	dname	=	excluded.dname
;

Want to be

INSERT
INTO
	distributors
(
	did
,	dname
)
SELECT
	did
,	dname
FROM
	my_distributors	md
INNER JOIN
	company	cp
ON
	md.company_cd	=	cp.company_cd
AND	cp.delete_flg	=	FALSE
ON
	CONFLICT	ON	CONSTRAINT	distributors_pkey	DO
UPDATE
SET	dname	=	excluded.dname
;

Memo

なお、通常のinsert文であれば問題ない

-- after1
INSERT
INTO
	distributors
(
	did
,	dname
) VALUES
	(5, 'Gizmo Transglobal')
,	(6, 'Associated Computing, Inc')
ON
	CONFLICT(did)	DO
UPDATE
SET	dname		=	excluded.dname
;

-- after2
INSERT
INTO
	distributors
(
	did
,	dname
) VALUES (
	9
,	'Antwerp Design'
)
ON
	CONFLICT	ON	CONSTRAINT	distributors_pkey	DO	nothing
;
@ma91n ma91n added the bug label Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant