-
Notifications
You must be signed in to change notification settings - Fork 18
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
fix: incoherency allowed characters tableName/columnName (+ improved regex & docs) #4173
Conversation
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.
looks good, let me know when finished
integrated #4172 |
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.
nice. Small comments. I particular make sure that user documentation starts with human explanation and then add regexp for the tech reader.
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.
Looks good. I think some minor revisions to the error message could help make it clearer for end users. Perhaps something like this:
Table names must start with a letter followed by one or more letters, numbers or underscores. Names cannot exceed 31 characters. Spaces are also allowed as long as they do not occur immediately before or after an underscore.
We could also have a few examples: My table
, myTable
, my_table
, My table 2
, etc.
@@ -0,0 +1,30 @@ | |||
import { test, expect } from '@playwright/test'; | |||
|
|||
let regexErrorMessage='Table name must start with a letter, followed by letters/underscores/spaces/numbers (though no underscore preceded/followed by a space) and with a maximum of 31 characters, i.e. ^(?!.* _|.*_ )[a-zA-Z][a-zA-Z0-9 _]{0,30}$' |
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.
Unless the message is reassigned, const
should be used here instead of let
.
@@ -178,7 +179,7 @@ export default { | |||
) { | |||
return undefined; | |||
} else { | |||
return "Table name must start with a letter, followed by letters, underscores, a space or numbers, i.e. [a-zA-Z][a-zA-Z0-9_]*. Maximum length: 31 characters"; | |||
return "Table name must start with a letter, followed by letters/underscores/spaces/numbers (though no underscore preceded/followed by a space) and with a maximum of 31 characters, i.e. ^(?!.* _|.*_ )[a-zA-Z][a-zA-Z0-9 _]{0,30}$"; |
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.
Should we put the regex pattern in the error message? It is helpful for developers, but I'm not sure if many end users (data managers, lab personnel, etc.) would understand this.
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.
Fair point. I left it in as they were present already, though for a user (without IT background) it indeed can just cause confusion.
if (!this.column.name.match(/^[a-zA-Z][a-zA-Z0-9_ ]+$/)) { | ||
return "Name should start with letter, followed by letter, number, whitespace or underscore ([a-zA-Z][a-zA-Z0-9_ ]*)"; | ||
if (!this.column.name.match(constants.COLUMN_NAME_REGEX)) { | ||
return "Name should start with a letter, followed by letters/underscores/spaces/numbers (though no underscore preceded/followed by a space), i.e. ^(?!.* _|.*_ )[a-zA-Z][a-zA-Z0-9 _]*$"; |
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.
(See comment above)
) { | ||
return "Name is required and can only contain 'azAZ_ '"; | ||
return "Name is required and must start with a letter, followed by letters/underscores/spaces/numbers (though no underscore preceded/followed by a space) and with a maximum of 31 characters, i.e. ^(?!.* _|.*_ )[a-zA-Z][a-zA-Z0-9 _]{0,30}$"; |
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.
(Same as above)
|
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.
Looks great!
Quality Gate passedIssues Measures |
What are the main changes you did:
how to test:
todo: