-
-
Notifications
You must be signed in to change notification settings - Fork 380
feat: make create database dialog select default charset and collation #973
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
feat: make create database dialog select default charset and collation #973
Conversation
|
Thanks for the PR. How this will work for Postgresql? |
|
It doesn't change anything for Postgresql. It will show up exactly as before. |
|
No I mean we should also select default values for Postgres as well |
995fad2 to
3ea82f6
Compare
|
Updated the commit. This will gracefully fallback to current behavior if the default charset or collation doesn't exist. |
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.
Pull request overview
This PR adds support for automatically selecting default charset and collation values when creating databases, matching MySQL 8+ defaults. The changes gracefully handle cases where the specified charset or collation doesn't exist on the server.
- Determines database type and sets appropriate defaults (UTF8/C.utf8 for PostgreSQL, utf8mb4/utf8mb4_0900_ai_ci for MySQL)
- Updates the CreateDatabase component to accept and use these default values
- Modifies the useEffect to load collations based on the form's current charset rather than only the default
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| resources/js/pages/databases/index.tsx | Adds logic to determine database type and set appropriate default charset/collation values, then passes them to the CreateDatabase component |
| resources/js/pages/databases/components/create-database.tsx | Updates the useEffect to use form.data.charset instead of defaultCharset for loading collations dynamically |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| useEffect(() => { | ||
| if (open && defaultCharset && charsets.includes(defaultCharset) && collations.length === 0) { | ||
| axios.get(route('databases.collations', { server: server, charset: defaultCharset })).then((response) => { | ||
| if (open && form.data.charset && charsets.includes(form.data.charset) && collations.length === 0) { | ||
| axios.get(route('databases.collations', { server: server, charset: form.data.charset })).then((response) => { | ||
| setCollations(response.data); | ||
| }); | ||
| } | ||
| }, [open, charsets, defaultCharset, server, collations]); | ||
| }, [open, charsets, form.data.charset, server, collations]); |
Copilot
AI
Jan 1, 2026
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.
The collations state is not reset when the modal closes or when the form is submitted successfully. This means that on subsequent opens of the modal, the useEffect will not run because the condition 'collations.length === 0' will be false, and the collations list will still contain values from the previous interaction. Consider resetting the collations state in the handleOpenChange function when open is false, or after form submission.
| </a> | ||
| <SyncDatabases server={page.props.server} /> | ||
| <CreateDatabase server={page.props.server.id}> | ||
| <CreateDatabase server={page.props.server.id} defaultCharset={defaultCharset} defaultCollation={defaultCollation}> |
Copilot
AI
Jan 1, 2026
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.
There are two consecutive spaces between the server prop and defaultCharset prop. Remove the extra space for consistent formatting.
| <CreateDatabase server={page.props.server.id} defaultCharset={defaultCharset} defaultCollation={defaultCollation}> | |
| <CreateDatabase server={page.props.server.id} defaultCharset={defaultCharset} defaultCollation={defaultCollation}> |
Matches defaults in MySQL 8+. Doesn't throw error if charset or collection doesn't exist.
Fixes #939 #760