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

missing FROM-clause entry for table: last arg replaces table with last_subquery #54

Open
socialwyze-franklin opened this issue Feb 12, 2021 · 0 comments

Comments

@socialwyze-franklin
Copy link

Offending line

I have an Objection QueryBuilder that produces the following SQL:

SELECT
	my_table.*
FROM
	my_table
	INNER JOIN other_table1 ON 1=1
	INNER JOIN other_table2 ON 1=1
WHERE
	other_table2.thing = ?

cursorPagination produces this SQL which results in Postgres returning the error missing FROM-clause entry for table "my_table"

SELECT
	* 
FROM
	(
	SELECT
		my_table.*,
	FROM
		my_table
	  INNER JOIN other_table1 ON 1=1
  	INNER JOIN other_table2 ON 1=1
  WHERE
	  other_table2.thing = ?
	ORDER BY
		"id" DESC,
		"id" DESC 
		LIMIT $2 
	) AS "last_subquery"
	INNER JOIN other_table1 ON 1=1
	INNER JOIN other_table2 ON 1=1
ORDER BY
	"id" ASC,
	"id" ASC
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

1 participant