Skip to content

Conversation

@naronchen
Copy link
Contributor

Copy link
Contributor Author

@naronchen naronchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIP

}
case Exp::Type::SqlColumnName:
{
NativeSqlBuilder sqlSnippet;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can also just append the resolved path here?

@aruniverse aruniverse closed this Apr 25, 2025
@aruniverse aruniverse deleted the exp_values branch April 25, 2025 14:37
@ColinKerr ColinKerr restored the exp_values branch April 28, 2025 11:45
@akshay-nangare akshay-nangare self-assigned this Apr 29, 2025
@akshay-nangare akshay-nangare marked this pull request as ready for review May 6, 2025 07:16
@akshay-nangare akshay-nangare linked an issue May 6, 2025 that may be closed by this pull request
}
}

TEST_F(ECSqlStatementTestFixture, ValuesClauseTest) {
Copy link
Contributor

@khanaffan khanaffan May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is some test we should add in this PR

  1. SELECT column1, column2 FROM (VALUES(1,2)) UNION SELECT column1, column2 FROM (VALUES(3,4));
  2. SELECT * FROM (SELECT column1 a, column2 b FROM (VALUES(1,2)))
  3. SELECT * FROM (VALUES(1,2)) a, (VALUES(2,3)) b
  4. SELECT * FROM (VALUES(1,2)) a, (VALUES(2,3)) b WHERE a.Column2=2
  5. SELECT * FROM (VALUES(?,?),(?,?)) a bind parameter and test

Copy link
Contributor

@khanaffan khanaffan May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

report this as issue for future work

I also noted that following, but column1_1 or column2_1 cannot be accessed in WHERE clause instead we have to use b.column1 and b.column2 to access it.

iModelConsole> SELECT * FROM (VALUES(1,2)) a, (VALUES(2,3)) b;

column1           |column2           |column1_1         |column2_1
---------------------------------------------------------------------------
1                 |2                 |2                 |3

Copy link
Contributor

@khanaffan khanaffan May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fixed in this PR.

There is no type checking e.g. Normally if a user uses a different type for the same column in different rows and its constant literal then we should fail if the type is different.

iModelConsole> .metadata SELECT * FROM (VALUES('dd',2),('333',4)) a;

Column metadata
===============
Index   Name/PropertyPath                   DisplayLabel                        System   Type                      Root class                     Root class alias
------------------------------------------------------------------------------------------------------------------------------------------------------------------
  0     column1                             column1                             no       String                    generated
  1     column2                             column2                             no       Long                      generated

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no type checking e.g. Normally if a user uses a different type for the same column in different rows and its constant literal then we should fail if the type is different.

I checked this in SQLite playground and SELECT * FROM (VALUES('dd',2),('333',4)) a; query passes on 4 different playgrounds.

SQLite uses dynamic typing and a concept called type affinity. This means that even if you declare a column to be of a certain type (e.g., INTEGER), SQLite will not strictly enforce it. You can insert different types (e.g., string, float, blob) into that column without errors.

Copy link
Contributor

@khanaffan khanaffan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added few mandory work that include add test and validate type of constant literal provided as values if more than one row is specified.

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.

ECSQL with VALUES(...),(...) has a limit

5 participants