mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-24 03:16:12 -05:00
Escape the given tablename in the engine_table_reader (#2958)
This commit is contained in:
@@ -61,7 +61,7 @@ func NewSqlEngineReader(ctx context.Context, dEnv *env.DoltEnv, tableName string
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sch, iter, err := se.Query(sqlCtx, fmt.Sprintf("SELECT * FROM %s", tableName))
|
||||
sch, iter, err := se.Query(sqlCtx, fmt.Sprintf("SELECT * FROM `%s`", tableName))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ func (s *SqlEngineTableWriter) TableSchema() sql.PrimaryKeySchema {
|
||||
// forceDropTableIfNeeded drop the given table in case the -f parameter is passed.
|
||||
func (s *SqlEngineTableWriter) forceDropTableIfNeeded() error {
|
||||
if s.force {
|
||||
_, _, err := s.se.Query(s.sqlCtx, fmt.Sprintf("DROP TABLE IF EXISTS %s", s.tableName))
|
||||
_, _, err := s.se.Query(s.sqlCtx, fmt.Sprintf("DROP TABLE IF EXISTS `%s`", s.tableName))
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ func (s *SqlEngineTableWriter) createOrEmptyTableIfNeeded() error {
|
||||
case CreateOp:
|
||||
return s.createTable()
|
||||
case ReplaceOp:
|
||||
_, _, err := s.se.Query(s.sqlCtx, fmt.Sprintf("TRUNCATE TABLE %s", s.tableName))
|
||||
_, _, err := s.se.Query(s.sqlCtx, fmt.Sprintf("TRUNCATE TABLE `%s`", s.tableName))
|
||||
return err
|
||||
default:
|
||||
return nil
|
||||
|
||||
@@ -719,7 +719,7 @@ DELIM
|
||||
|
||||
@test "import-update-tables: import supports tables with dashes in the name" {
|
||||
cat <<DELIM > file.csv
|
||||
pk, c1
|
||||
pk,c1
|
||||
0,0
|
||||
DELIM
|
||||
|
||||
@@ -727,7 +727,11 @@ DELIM
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "Import completed successfully." ]] || false
|
||||
|
||||
skip "This fails right now with syntax error at position 20 near 'this'"
|
||||
run dolt table import -u this-is-a-table file.csv
|
||||
[ $status -eq 0 ]
|
||||
|
||||
run dolt sql -r csv -q "SELECT * FROM \`this-is-a-table\`"
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "pk,c1" ]] || false
|
||||
[[ "$output" =~ "0,0" ]] || false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user