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

Module lint and clean up. Implemented fixes from testing on Azure #57

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

wilr
Copy link
Member

@wilr wilr commented Oct 12, 2020

Deployed to Azure MSSQL and confirmed dev/build

Copy link
Contributor

@dhensby dhensby left a comment

Choose a reason for hiding this comment

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

Amazing work, thanks for doing this.

Only a couple of questions.

I also think that this should probably constitute a new major release, especially if some of the APIs are being removed - that means bumping the master alias in composer.json.

@@ -143,18 +161,34 @@ public function preparedQuery($sql, $parameters, $errorLevel = E_USER_ERROR)

// Check for error
if (!$handle) {
$error = $this->getLastError();

if (preg_match("/Cannot insert explicit value for identity column in table '(.*)'/", $error, $matches)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems risky - if the database has SET_IDENTITY_INSERT off then we shouldn't be turning it on to force the query. The application should assume the that DB Server is correctly configured, rather than running these implicit queries.

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe that IDENTITY INSERT can only be overridden one table at a time, per connection and there isn't a global method configuration option for it?

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm - inserting with ID values is pretty central to SS - it's required for almost all our ORM inserts where there's MTI in play. Having logic that runs a query, checks the error, runs another query, re-runs the original and then runs a fourth final query is going to have a massive impact on performance.

Not only that, SET_IDENTITY_INSERT requires ALTER permissions on the table, so anyone with appropriately locked down permissions for their app won't even be able to run the query anyway.

However, it does seem to be somewhat impossible to have an autoincrement value in MSSQL without using the IDENTITY type. This just provides more reason why we shouldn't rely on the DB layer to produce PK values in SS.

In conclusion, it looks like we have pretty much no choice about this and we should probably accept that MSSQL is not a good DBMS to be using with SS. :(

@@ -43,27 +47,10 @@ public function __destruct()
}
}

public function getIterator()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why has this generator been replaced with the old style API? #49

Copy link
Member Author

Choose a reason for hiding this comment

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

@dhensby I take it getIterator is for SS5 not SS4 though? I was trying to get compatibility with SS 4.6

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm - ok, then we need to do some branch management on this repo, it seems.

* @param string $tableName
* @return string|null
*/
public function getIdentityColumn($tableName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why has this function been removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

As far as I could see it was no longer used anywhere?

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.

None yet

2 participants