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

Fix #1616: INSERT INTO with a SELECT * FROM and a subquery throws exception #1624

Merged
merged 1 commit into from
Jan 19, 2023
Merged

Fix #1616: INSERT INTO with a SELECT * FROM and a subquery throws exception #1624

merged 1 commit into from
Jan 19, 2023

Conversation

ambujsahu81
Copy link
Contributor

What is the PR `for?

  • It is an attempt to fix the issue #1616

Description :

  • It seems that the statement alasql.exec('SELECT * FROM t2 WHERE val = (SELECT val FROM t3 WHERE id= 2)') work fine without throwing any errors. And the ast object has statement property which contain sql statement itself at index 0. this property contains queries object. Something like this :
SELECT * FROM t2 WHERE val = SELECT val FROM t3 WHERE id = 2
statements: (1) [yy.Select]
      0: SELECT * FROM t2 WHERE val = SELECT val FROM t3 WHERE id = 2
            columns: (1) [Column]
            from:  (1) [Table]
            queries: (1) [yy.Select]    // <-   This property is present here
            where:  val = SELECT val FROM t3 WHERE id = 2
  • But for the statement alasql.exec('INSERT INTO t SELECT * FROM t2 WHERE val = (SELECT val FROM t3 WHERE id= 2)') queries property is present in insert object which also contain nested select Object where queries property is missing For example
INSERT INTO t SELECT * FROM t2 WHERE val = SELECT val FROM t3 WH
statements:(1) [yy.Insert]
	0: INSERT INTO t SELECT * FROM t2 WHERE val = SELECT val FROM t3 WH
	     into: t
	    queries: (1) [yy.Select]  // present here
	     select: SELECT * FROM t2 WHERE val = SELECT val FROM t3 WHERE id = 2
		columns:(1) [Column]
		from: (1) [Table]  // missing here
		where: val = SELECT val FROM t3 WHERE id = 2
  • To avoid the exception the code changes adds the missing queries property in nested select object

@ambujsahu81 ambujsahu81 changed the title Fix subquery in insert statement throw exceptions. Fix (#1616): INSERT INTO with a SELECT * FROM and a subquery throws exception . Jan 19, 2023
@mathiasrw
Copy link
Member

Thank you so much!

@mathiasrw mathiasrw changed the title Fix (#1616): INSERT INTO with a SELECT * FROM and a subquery throws exception . Fix (#1616): INSERT INTO with a SELECT * FROM and a subquery throws exception Jan 19, 2023
@mathiasrw mathiasrw merged commit 0e8a555 into AlaSQL:develop Jan 19, 2023
@mathiasrw
Copy link
Member

Released as part of v2.5.3

@mathiasrw mathiasrw changed the title Fix (#1616): INSERT INTO with a SELECT * FROM and a subquery throws exception Fix #1616: INSERT INTO with a SELECT * FROM and a subquery throws exception Jan 19, 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

Successfully merging this pull request may close these issues.

2 participants