MCPcopy
hub / github.com/sqldef/sqldef / TestDefaultFunctionExpressions

Function TestDefaultFunctionExpressions

parser/parser_test.go:740–775  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

738}
739
740func TestDefaultFunctionExpressions(t *testing.T) {
741 testCases := []struct {
742 name string
743 sql string
744 mode ParserMode
745 }{
746 {
747 name: "MySQL JSON_ARRAY default wrapped in parentheses",
748 sql: "CREATE TABLE t (id bigint, friend_ids JSON DEFAULT(JSON_ARRAY()))",
749 mode: ParserModeMysql,
750 },
751 {
752 name: "Postgres uuid_generate_v4 default",
753 sql: "CREATE TABLE t (id uuid DEFAULT uuid_generate_v4())",
754 mode: ParserModePostgres,
755 },
756 {
757 name: "Postgres gen_random_uuid default",
758 sql: "CREATE TABLE t (id uuid DEFAULT gen_random_uuid())",
759 mode: ParserModePostgres,
760 },
761 {
762 name: "Postgres now default stays a function call",
763 sql: "CREATE TABLE t (created_at timestamp DEFAULT now())",
764 mode: ParserModePostgres,
765 },
766 }
767
768 for _, tc := range testCases {
769 t.Run(tc.name, func(t *testing.T) {
770 if _, err := ParseDDL(tc.sql, tc.mode); err != nil {
771 t.Fatalf("ParseDDL(%q) failed: %v", tc.sql, err)
772 }
773 })
774 }
775}
776
777func TestSQLiteTableOptions(t *testing.T) {
778 testCases := []struct {

Callers

nothing calls this directly

Calls 2

ParseDDLFunction · 0.85
FatalfMethod · 0.65

Tested by

no test coverage detected