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

Why can column names not begin with an underscore? #210

Open
EternityForest opened this issue Nov 9, 2020 · 1 comment
Open

Why can column names not begin with an underscore? #210

EternityForest opened this issue Nov 9, 2020 · 1 comment

Comments

@EternityForest
Copy link

Many non-SQL databases use column names with underscores at the begining(PouchDB's _id field, etc). Is there a specific reason the schemas don't support this, or any flag to enable it?

@juanreynolds
Copy link

juanreynolds commented Oct 24, 2021

I would also like to know. Does not look like there is an option t set it as the code has checks like this:

if (!table._internal && (l.indexOf("_") === 0 || l.match(/\s/g) !== null || l.match(/[\(\)\]\[\.]/g) !== null)) {
                rej({ error: "Invalid Table Name " + table.name + "! https://docs.nanosql.io/setup/data-models", query: _this.query });
                return;
            }
if (!modelData[0] || modelData[0].match(/[\(\)\]\[\.]/g) !== null || modelData[0].indexOf("_") === 0) {
                    hasError = true;
                    rej({ error: "Invalid Data Model at " + (table.name + "." + col) + "! https://docs.nanosql.io/setup/data-models", query: _this.query });
                }

If I alter the code to exclude the check for the undescore prefix then it works perfectly fine. Maybe one of the adapters does not like it, in which case it would be possible to then add a config for it to allow it.

UPDATE: So after further investigation it seems that nano-sql uses underscores internally for table creation (I observed with SQLite) and it disallows using underscores for table and db names so as to avoid collisions most probably..

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

No branches or pull requests

2 participants