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

Creating a table should automatically escape the name with quotes #378

Open
willium opened this issue May 4, 2024 · 0 comments
Open

Creating a table should automatically escape the name with quotes #378

willium opened this issue May 4, 2024 · 0 comments

Comments

@willium
Copy link
Member

willium commented May 4, 2024

It'd be great if a table name was escape with quotes automatically during creation.

+ name + ' AS ' + query;

I was going to send a PR for this by exporting quoteTableName from ref.js:

/**
* Quote a table name. For example, `foo.bar` becomes `"foo"."bar".
* @param {string} table the name of the table which may contain a database reference
* @returns The quoted table name.
*/
function quoteTableName(table) {
const pieces = table.split('.');
return pieces.map(p => `"${p}"`).join('.');
}

but I noticed we actually handle 'quoting' in several different places in mosaic-sql, so I'm not sure what the preferred way of addressing this (globally?) would be:

  • aggregates.js has unquoted
  • Query.js has unquote and isDoubleQuoted
  • ref.js has quoteTableName
@willium willium changed the title Creating a table should automatically escape it with quotes Creating a table should automatically escape the name with quotes May 4, 2024
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

1 participant