Skip to content

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

@socialwyze-franklin

Description

@socialwyze-franklin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions