-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
mssql: Improve estimate of max comment length #4362
mssql: Improve estimate of max comment length #4362
Conversation
@jeremy-w Considering that |
@kibertoad would the warning still be useful if we trapped the error during adding the comment and converted it into a more knex-relevant error? or would that do to replace the error? since the "length exceeded" error has Level 16 (greater than 10, less than 20), it looks like try…catch would work. |
@jeremy-w While we already have plenty of magic for handling MSSQL edge-cases, I would prefer to avoid adding even more unless strictly necessary. Just improving error messages doesn't sound like a big enough reason to complicate generated queries, so I would still prefer just a knex warning in this case. |
50ba27e
to
6906532
Compare
The tests in this file were not being picked up, because the file did not match the *.spec.js glob used by test/mocha-integration-config-test.js.
6906532
to
ba78b59
Compare
@kibertoad Updated with the requested tests. Also added a test to validate our "7500/4" estimate for when to warn is a good one. This also gets us most of the way to being able to generate comments as part of the schema builder, so things are looking good for #4204. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought of a couple issues overnight. i bet we can allow a 2x longer char count before warning due to how JS counts character length when characters outside the BMP get involved.
Turns out they have up to 7500/2 characters (as JavaScript's String.length counts them) before we have to worry about the encoded comment exceeding the 7500-byte limit.
ba78b59
to
f487809
Compare
OK, I addressed the issues I thought of, and I was able to provide a lot more headroom - comments have to be longer than 3,750 characters before comment length begins to be a concern! |
Thank you! |
Released in 0.95.3. |
Before, table comments used a limit of 60 chars (seemingly inherited from the MySQL dialect), while columns warned about exceeding a limit of 255 chars. This led to spurious warnings.
Now, warnings are only emitted if it seems possible for the comment to exceed the actual, documented 7,500 byte limit:
That limit proved to be when the
comment.length
exceeded 7500/2, as demonstrated by testing.(This is a small step towards #4204.)
Questions for Reviewers
Making the warning more precise:
Should we even bother warning at all? When we get around to actually adding the comments, MSSQL will raise an error if the length is exceeded for us: