FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Replace non-alphanumeric with underscore by kor44 · Pull Request #4166 · sqlitebrowser/sqlitebrowser · GitHub

Replace non-alphanumeric with underscore - #4166

Merged
mgrojo merged 3 commits into
sqlitebrowser:masterfrom
kor44:master
Jul 31, 2026
Merged

Replace non-alphanumeric with underscore#4166
mgrojo merged 3 commits into
sqlitebrowser:masterfrom
kor44:master

Conversation

kor44 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Added option to replace non-alphanumeric characters in column name with underscore. SQL editor does not complete correctly column names containing space, column and etc. This is example CSV

Option location

Michail Koreshkov and others added 2 commits March 29, 2026 12:00
Added option to replace non-alphanumeric characters in column name with
underscore. SQL editor does not complete correctly column names
containing space, column and etc.
Comment thread src/ImportCsvDialog.cpp Outdated
// Take field name from CSV
fieldname = std::string(rowData.fields[i].data, rowData.fields[i].data_length);

// Replace any non-nlphanumeric characters with an underscore

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
// Replace any non-nlphanumeric characters with an underscore
// Replace any non-alphanumeric character with an underscore

Comment thread src/ImportCsvDialog.cpp Outdated
// Replace any non-nlphanumeric characters with an underscore
if(ui->checkReplaceNonAlnum->isChecked())
{
std::regex pattern("[^a-zA-Z0-9_]");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This will treat international letters as non-valid. Is that what we want?

This alternative will support Unicode letters:

for (QChar &c : fieldname)
    if (!c.isLetterOrNumber() && c != '_')
        c = '_';

What I saw is that the special characters don't trigger the completion list (if present in the first characters), but can be completed if the first 3 characters are ASCII. Not sure what we should do; maybe your simple approach is the best option.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This will treat international letters as non-valid. Is that what we want?

This alternative will support Unicode letters:

for (QChar &c : fieldname)
    if (!c.isLetterOrNumber() && c != '_')
        c = '_';

What I saw is that the special characters don't trigger the completion list (if present in the first characters), but can be completed if the first 3 characters are ASCII. Not sure what we should do; maybe your simple approach is the best option.

As fieldname is std::string I used conversion to/from QString.

What I saw is that the special characters don't trigger the completion list (if present in the first characters), but can be completed if the first 3 characters are ASCII. Not sure what we should do; maybe your simple approach is the best option.

The problem with QScintilla which inserts text up to first space. I have tried to change behavior, but it was complex and came to this idea (replace non_alnum by _)

mgrojo merged commit d38a6c7 into sqlitebrowser:master Jul 31, 2026
21 of 23 checks passed

mgrojo commented Jul 31, 2026

Copy link
Copy Markdown
Member

Perfect, @kor44, thanks for the contribution.

Copy link
Copy Markdown
Member

@mgrojo There is currently an issue with the CI workflow, and I will fix it by this morning. :)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL