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

Add values functions #69

Open
Sytten opened this issue Jan 12, 2021 · 2 comments
Open

Add values functions #69

Sytten opened this issue Jan 12, 2021 · 2 comments

Comments

@Sytten
Copy link

Sytten commented Jan 12, 2021

I was trying to do something similar to https://stackoverflow.com/questions/34708509/how-to-use-returning-with-on-conflict-in-postgresql/42217872#42217872

WITH input_rows(usr, contact, name) AS (
   VALUES
      (text 'foo1', text 'bar1', text 'bob1')  -- type casts in first row
    , ('foo2', 'bar2', 'bob2')
    -- more?
   )

But I don't think there is a VALUES function.

@Sytten
Copy link
Author

Sytten commented Jan 12, 2021

Looking at it, the WRAP function will be needed for that #67

@go-jet
Copy link
Owner

go-jet commented Jan 17, 2021

Yeah, VALUES statement is not implemented yet.
SELECT can be used for one row and SELECT with UNION ALL can be used for multiple rows. For instance:

input_rows := CTE("input_rows")

stmt := WITH(
	input_rows.AS(
		UNION_ALL(
                        // first row columns has to be aliased
			SELECT(String("foo1").AS("foo"), String("bar1").AS("bar"), String("bob1").AS("bob")),
			SELECT(String("foo2"), String("bar2"), String("bob2")),
		),
	),
)(
	SELECT(input_rows.AllColumns()).
		FROM(input_rows),
)

@go-jet go-jet added this to the Version 2.11.0 milestone Apr 29, 2023
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