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

#4667 Fix Sqlsrv Setup #4668

Closed
wants to merge 13 commits into from
Closed

#4667 Fix Sqlsrv Setup #4668

wants to merge 13 commits into from

Conversation

FrankWarius
Copy link

No description provided.

@FrankWarius FrankWarius marked this pull request as ready for review December 17, 2022 09:28
@fisharebest
Copy link
Owner

Hi Frank,

Can you run some tests for me.

  1. You set IDENTITY_INSERT OFF after each insert.

We didn't do this in the previous code (But that code did not work...!).

Can you check that this statement is required. e.g. will it work without it.

  1. In SQL-Server, I think that you use [ and ] to quote table names. This can be important if the prefix contains special characters.

Can you tell me if it still works when you replace
'SET IDENTITY_INSERT ' . $prefix . 'user ON'
with
'SET IDENTITY_INSERT [' . $prefix . 'user] ON'

@FrankWarius
Copy link
Author

Hi Greg

  1. You set IDENTITY_INSERT OFF after each insert.

I followed https://stackoverflow.com/questions/56560556/insert-data-in-laravel-identity-insert-is-set-to-off.
it seems You have to switch it On and OFF for every table.
Your actual fixes work for all migration scripts

  1. In SQL-Server, I think that you use [ and ] to quote table names. This can be important if the prefix contains special characters.

Done and pushed.

Migration finished with creation of Config.ini.php but has an major issue with session table see #4669

@fisharebest
Copy link
Owner

Can you tell me if it is necessary to use ->unprepared().
Will it also work wtih ->statement()?

@codecov
Copy link

codecov bot commented Dec 22, 2022

Codecov Report

Merging #4668 (6bd4818) into main (3a3594e) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

@@             Coverage Diff              @@
##               main    #4668      +/-   ##
============================================
- Coverage     30.94%   30.93%   -0.01%     
- Complexity    11333    11337       +4     
============================================
  Files          1189     1189              
  Lines         47807    47818      +11     
============================================
  Hits          14792    14792              
- Misses        33015    33026      +11     
Impacted Files Coverage Δ
app/Schema/Migration44.php 0.00% <ø> (ø)
app/Schema/SeedGedcomTable.php 0.00% <0.00%> (ø)
app/Schema/SeedUserTable.php 0.00% <0.00%> (ø)
app/Services/ServerCheckService.php 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@fisharebest
Copy link
Owner

Your PR adds some entries to .gitignore

It is recommended that this type of file are added to your global .gitignore file - not the project file.

I merged the SET IDENTITY_INSERT changes in 736b8b7

@FrankWarius
Copy link
Author

Can you tell me if it is necessary to use ->unprepared(). Will it also work wtih ->statement()?

I doesn't test statement(). I found https://stackoverflow.com/questions/56560556/insert-data-in-laravel-identity-insert-is-set-to-off. and there You found

You can use DB::unprepared() instead of DB::statement().
The difference is that statement() executes a prepared statement, while unprepared() uses PDO::exec() instead.

Every prepared statement starts a new session (inside the same database connection) and because the SET IDENTITY_INSERT query is session-specific, it doesn't affect other prepared statements like the INSERT query.

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