Skip to content

SQL exporter doesn't create compliant column names #1940

Description

@stevevance

Describe the bug
The SQL exporter will not create SQL-compliant column names. If a column has spaces, they are replaced with "-" by default, and replaced with nothing if the "Trim Column Names" checkbox is unchecked. Hyphens are not an acceptable character in a SQL column name.

To Reproduce
Steps to reproduce the behavior:

  1. Open a dataset that has column names with spaces in them.
  2. Click Export>SQL Exporter.
  3. Click "Download" tab.
  4. Click Preview
  5. Attempt to create a table in an SQL database with the SQL exported by OpenRefine. It will not create, and SQL will print an error like:
ERROR:  syntax error at or near "-"
LINE 11: Line1-Street TEXT NULL,
              ^

Current Results
What results occured or were shown.

Expected behavior
The SQL Exporter should, by default, convert column names to an SQL-compliant name, replacing spaces and other illegal characters with "_" (underscore). Column names can also not begin with numbers. They cannot have single quotes or punctuation.

Screenshots
image
image
image

Desktop (please complete the following information):

  • OS: Mac 10.14.2
  • Browser Version: Safari 12.0.2
  • JRE or JDK Version: 1.8.0_121

OpenRefine (please complete the following information):

Metadata

Metadata

Assignees

Labels

Good First IssueIndicates issues suitable for newcomers to design or coding, providing a gentle introduction.SQL/databaseIntegration with SQL databases in generalType: BugIssues related to software defects or unexpected behavior, which require resolution.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions