-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replacing SF tableNameComponents with PG's version
- Loading branch information
1 parent
2f18f76
commit 2be8bf0
Showing
5 changed files
with
32 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
package utils | ||
|
||
import "fmt" | ||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
func QuoteIdentifier(identifier string) string { | ||
return fmt.Sprintf(`"%s"`, identifier) | ||
} | ||
|
||
// SchemaTable is a table in a schema. | ||
type SchemaTable struct { | ||
Schema string | ||
Table string | ||
} | ||
|
||
func (t *SchemaTable) String() string { | ||
return fmt.Sprintf(`"%s"."%s"`, t.Schema, t.Table) | ||
} | ||
|
||
// ParseSchemaTable parses a table name into schema and table name. | ||
func ParseSchemaTable(tableName string) (*SchemaTable, error) { | ||
schema, table, hasDot := strings.Cut(tableName, ".") | ||
if !hasDot || strings.ContainsRune(table, '.') { | ||
return nil, fmt.Errorf("invalid table name: %s", tableName) | ||
} | ||
|
||
return &SchemaTable{schema, table}, nil | ||
} |
This file contains 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