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

Offset for sqlsrv breaks queries with row_num column #44354

Closed
dunhamjared opened this issue Sep 28, 2022 · 5 comments
Closed

Offset for sqlsrv breaks queries with row_num column #44354

dunhamjared opened this issue Sep 28, 2022 · 5 comments

Comments

@dunhamjared
Copy link
Contributor

  • Laravel Version: 9.x
  • PHP Version: 8.1
  • Database Driver & Version: SQLServer

Description

PR #39863 introduces two issues.

If offset is used for SQL Server:

  1. You cannot use row_num as a column name or alias
  2. An unexpected column row_num is included in the results

Examples

Scenario 1

If you have a row_num column or alias, SQL Server will throw:

SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The column 'row_num' was specified multiple times for 'temp_table'

Scenario 2

If you try to insert the offset results into the same table by using chunk:

db()->connection('db_1')->table('example')->chunk(500, function($chunk){
    db()->connection('db_2')->table('example')->insert($chunk);
});

row_num is added to the results and is an unexpected column, causing SQL server to throw:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'row_num' in 'field list'
@driesvints
Copy link
Member

Seems like a PR was sent in so let's see how it goes. Thanks

@dunhamjared
Copy link
Contributor Author

@driesvints could you reopen the issue since it is still active?

@driesvints
Copy link
Member

@dunhamjared it looks like taylor doesn't wants to merge this right now. It's best that you gather some feedback from other SQL Server users first.

@driesvints
Copy link
Member

Try to gather some feedback on the draft PR you sent in.

@dunhamjared
Copy link
Contributor Author

@driesvints will do, thanks!

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 a pull request may close this issue.

2 participants