Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This one still needs a bit of work to do.
Since SQL Server upsert works with the
merge
statement in Laravel, we need to rely on a physical key_hash column with pre-generated hashes like in sqlite and cannot go the mysql, mariadb and postgres way by using a virtual column - even if SQL Server supports this by using computed columns. A quick example on that:This issue lies in
laravel_source
(the source table to be compared in the merge statement) not having thekey_hash
column- this makes the join condition
[laravel_source].[key_hash] = [pulse_values].[key_hash]
invalid.We could create computed columns for the
key_hash
...:... but doing that, we will get a SQL Error because the
merge
query will try to insert or update thekey_hash
column - which isnot possible, because this one is a non-writable, computed value. That's why I went with creating a string with the length of
32, which is the md5 string representation.
I am using
[laravel_source]
as hard coded alias for the upserts, since the current implementation in Laravel also does that. See as seen in SqlGrammar::compileUpsert()This one still needs a bit of work with some digging being involved. Another issue that I've been facing is the problem of the sqlsrv driver returning values as a string - that results in failing test with messages like...
and
or
As you can see, the values match, but the types don't.
The official SQL Server PHP Driver gives us the
PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE
attribute which should give us numeric casts. I just don't know how to enable them during testing and casting the expected values explicitly to integer feels "wrong" to me.Calling
DB::connection('sqlsrv')->getPdo()->setAttribute(PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, true)
in thebeforeEach
closure didn't help.I've also faced a weird error regarding transactions, but that might be because I'm still using msodbcsql17 instead of the current msodbcsql18.
This happened to me in the
one or more aggregates for a single type
test:At least it is something in the current state: