...

Source file src/github.com/doug-martin/goqu/v9/sqlgen/sql_dialect_options.go

Documentation: github.com/doug-martin/goqu/v9/sqlgen

     1  package sqlgen
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  
     7  	"github.com/doug-martin/goqu/v9/exp"
     8  )
     9  
    10  type (
    11  	SQLFragmentType   int
    12  	SQLDialectOptions struct {
    13  		// Set to true if the dialect supports ORDER BY expressions in DELETE statements (DEFAULT=false)
    14  		SupportsOrderByOnDelete bool
    15  		// Set to true if the dialect supports table hint for DELETE statements (DELETE t FROM t ...), DEFAULT=false
    16  		SupportsDeleteTableHint bool
    17  		// Set to true if the dialect supports ORDER BY expressions in UPDATE statements (DEFAULT=false)
    18  		SupportsOrderByOnUpdate bool
    19  		// Set to true if the dialect supports LIMIT expressions in DELETE statements (DEFAULT=false)
    20  		SupportsLimitOnDelete bool
    21  		// Set to true if the dialect supports LIMIT expressions in UPDATE statements (DEFAULT=false)
    22  		SupportsLimitOnUpdate bool
    23  		// Set to true if the dialect supports RETURN expressions (DEFAULT=true)
    24  		SupportsReturn bool
    25  		// Set to true if the dialect supports Conflict Target (DEFAULT=true)
    26  		SupportsConflictTarget bool
    27  		// Set to true if the dialect supports Conflict Target (DEFAULT=true)
    28  		SupportsConflictUpdateWhere bool
    29  		// Set to true if the dialect supports Insert Ignore syntax (DEFAULT=false)
    30  		SupportsInsertIgnoreSyntax bool
    31  		// Set to true if the dialect supports Common Table Expressions (DEFAULT=true)
    32  		SupportsWithCTE bool
    33  		// Set to true if the dialect supports recursive Common Table Expressions (DEFAULT=true)
    34  		SupportsWithCTERecursive bool
    35  		// Set to true if multiple tables are supported in UPDATE statement. (DEFAULT=true)
    36  		SupportsMultipleUpdateTables bool
    37  		// Set to true if DISTINCT ON is supported (DEFAULT=true)
    38  		SupportsDistinctOn bool
    39  		// Set to true if LATERAL queries are supported (DEFAULT=true)
    40  		SupportsLateral bool
    41  		// Set to false if the dialect does not require expressions to be wrapped in parens (DEFAULT=true)
    42  		WrapCompoundsInParens bool
    43  
    44  		// Set to true if window function are supported in SELECT statement. (DEFAULT=true)
    45  		SupportsWindowFunction bool
    46  
    47  		// Set to true if the dialect requires join tables in UPDATE to be in a FROM clause (DEFAULT=true).
    48  		UseFromClauseForMultipleUpdateTables bool
    49  
    50  		// Surround LIMIT parameter with parentheses, like in MSSQL: SELECT TOP (10) ...
    51  		SurroundLimitWithParentheses bool
    52  
    53  		// The UPDATE fragment to use when generating sql. (DEFAULT=[]byte("UPDATE"))
    54  		UpdateClause []byte
    55  		// The INSERT fragment to use when generating sql. (DEFAULT=[]byte("INSERT INTO"))
    56  		InsertClause []byte
    57  		// The INSERT IGNORE INTO fragment to use when generating sql. (DEFAULT=[]byte("INSERT IGNORE INTO"))
    58  		InsertIgnoreClause []byte
    59  		// The SELECT fragment to use when generating sql. (DEFAULT=[]byte("SELECT"))
    60  		SelectClause []byte
    61  		// The DELETE fragment to use when generating sql. (DEFAULT=[]byte("DELETE"))
    62  		DeleteClause []byte
    63  		// The TRUNCATE fragment to use when generating sql. (DEFAULT=[]byte("TRUNCATE"))
    64  		TruncateClause []byte
    65  		// The WITH fragment to use when generating sql. (DEFAULT=[]byte("WITH "))
    66  		WithFragment []byte
    67  		// The RECURSIVE fragment to use when generating sql (after WITH). (DEFAULT=[]byte("RECURSIVE "))
    68  		RecursiveFragment []byte
    69  		// The CASCADE fragment to use when generating sql. (DEFAULT=[]byte(" CASCADE"))
    70  		CascadeFragment []byte
    71  		// The RESTRICT fragment to use when generating sql. (DEFAULT=[]byte(" RESTRICT"))
    72  		RestrictFragment []byte
    73  		// The SQL fragment to use when generating insert sql and using
    74  		// DEFAULT VALUES (e.g. postgres="DEFAULT VALUES", mysql="", sqlite3=""). (DEFAULT=[]byte(" DEFAULT VALUES"))
    75  		DefaultValuesFragment []byte
    76  		// The SQL fragment to use when generating insert sql and listing columns using a VALUES clause
    77  		// (DEFAULT=[]byte(" VALUES "))
    78  		ValuesFragment []byte
    79  		// The SQL fragment to use when generating truncate sql and using the IDENTITY clause
    80  		// (DEFAULT=[]byte(" IDENTITY"))
    81  		IdentityFragment []byte
    82  		// The SQL fragment to use when generating update sql and using the SET clause (DEFAULT=[]byte(" SET "))
    83  		SetFragment []byte
    84  		// The SQL DISTINCT keyword (DEFAULT=[]byte(" DISTINCT "))
    85  		DistinctFragment []byte
    86  		// The SQL RETURNING clause (DEFAULT=[]byte(" RETURNING "))
    87  		ReturningFragment []byte
    88  		// The SQL FROM clause fragment (DEFAULT=[]byte(" FROM"))
    89  		FromFragment []byte
    90  		// The SQL USING join clause fragment (DEFAULT=[]byte(" USING "))
    91  		UsingFragment []byte
    92  		// The SQL ON join clause fragment (DEFAULT=[]byte(" ON "))
    93  		OnFragment []byte
    94  		// The SQL WHERE clause fragment (DEFAULT=[]byte(" WHERE "))
    95  		WhereFragment []byte
    96  		// The SQL GROUP BY clause fragment(DEFAULT=[]byte(" GROUP BY "))
    97  		GroupByFragment []byte
    98  		// The SQL HAVING clause fragment(DEFAULT=[]byte(" HAVING "))
    99  		HavingFragment []byte
   100  		// The SQL WINDOW clause fragment(DEFAULT=[]byte(" WINDOW "))
   101  		WindowFragment []byte
   102  		// The SQL WINDOW clause PARTITION BY fragment(DEFAULT=[]byte("PARTITION BY "))
   103  		WindowPartitionByFragment []byte
   104  		// The SQL WINDOW clause ORDER BY fragment(DEFAULT=[]byte("ORDER BY "))
   105  		WindowOrderByFragment []byte
   106  		// The SQL WINDOW clause OVER fragment(DEFAULT=[]byte(" OVER "))
   107  		WindowOverFragment []byte
   108  		// The SQL ORDER BY clause fragment(DEFAULT=[]byte(" ORDER BY "))
   109  		OrderByFragment []byte
   110  		// The SQL FETCH fragment(DEFAULT=[]byte(" "))
   111  		FetchFragment []byte
   112  		// The SQL LIMIT BY clause fragment(DEFAULT=[]byte(" LIMIT "))
   113  		LimitFragment []byte
   114  		// The SQL OFFSET BY clause fragment(DEFAULT=[]byte(" OFFSET "))
   115  		OffsetFragment []byte
   116  		// The SQL FOR UPDATE fragment(DEFAULT=[]byte(" FOR UPDATE "))
   117  		ForUpdateFragment []byte
   118  		// The SQL FOR NO KEY UPDATE fragment(DEFAULT=[]byte(" FOR NO KEY UPDATE "))
   119  		ForNoKeyUpdateFragment []byte
   120  		// The SQL FOR SHARE fragment(DEFAULT=[]byte(" FOR SHARE "))
   121  		ForShareFragment []byte
   122  		// The SQL OF fragment(DEFAULT=[]byte("OF "))
   123  		OfFragment []byte
   124  		// The SQL FOR KEY SHARE fragment(DEFAULT=[]byte(" FOR KEY SHARE "))
   125  		ForKeyShareFragment []byte
   126  		// The SQL NOWAIT fragment(DEFAULT=[]byte("NOWAIT"))
   127  		NowaitFragment []byte
   128  		// The SQL SKIP LOCKED fragment(DEFAULT=[]byte("SKIP LOCKED"))
   129  		SkipLockedFragment []byte
   130  		// The SQL AS fragment when aliasing an Expression(DEFAULT=[]byte(" AS "))
   131  		AsFragment []byte
   132  		// The SQL LATERAL fragment used for LATERAL joins
   133  		LateralFragment []byte
   134  		// The quote rune to use when quoting identifiers(DEFAULT='"')
   135  		QuoteRune rune
   136  		// The NULL literal to use when interpolating nulls values (DEFAULT=[]byte("NULL"))
   137  		Null []byte
   138  		// The TRUE literal to use when interpolating bool true values (DEFAULT=[]byte("TRUE"))
   139  		True []byte
   140  		// The FALSE literal to use when interpolating bool false values (DEFAULT=[]byte("FALSE"))
   141  		False []byte
   142  		// The ASC fragment when specifying column order (DEFAULT=[]byte(" ASC"))
   143  		AscFragment []byte
   144  		// The DESC fragment when specifying column order (DEFAULT=[]byte(" DESC"))
   145  		DescFragment []byte
   146  		// The NULLS FIRST fragment when specifying column order (DEFAULT=[]byte(" NULLS FIRST"))
   147  		NullsFirstFragment []byte
   148  		// The NULLS LAST fragment when specifying column order (DEFAULT=[]byte(" NULLS LAST"))
   149  		NullsLastFragment []byte
   150  		// The AND keyword used when joining ExpressionLists (DEFAULT=[]byte(" AND "))
   151  		AndFragment []byte
   152  		// The OR keyword used when joining ExpressionLists (DEFAULT=[]byte(" OR "))
   153  		OrFragment []byte
   154  		// The UNION keyword used when creating compound statements (DEFAULT=[]byte(" UNION "))
   155  		UnionFragment []byte
   156  		// The UNION ALL keyword used when creating compound statements (DEFAULT=[]byte(" UNION ALL "))
   157  		UnionAllFragment []byte
   158  		// The INTERSECT keyword used when creating compound statements (DEFAULT=[]byte(" INTERSECT "))
   159  		IntersectFragment []byte
   160  		// The INTERSECT ALL keyword used when creating compound statements (DEFAULT=[]byte(" INTERSECT ALL "))
   161  		IntersectAllFragment []byte
   162  		// The CAST keyword to use when casting a value (DEFAULT=[]byte("CAST"))
   163  		CastFragment []byte
   164  		// The CASE keyword to use when when creating a CASE statement (DEFAULT=[]byte("CASE "))
   165  		CaseFragment []byte
   166  		// The WHEN keyword to use when when creating a CASE statement (DEFAULT=[]byte(" WHEN "))
   167  		WhenFragment []byte
   168  		// The THEN keyword to use when when creating a CASE statement (DEFAULT=[]byte(" THEN "))
   169  		ThenFragment []byte
   170  		// The ELSE keyword to use when when creating a CASE statement (DEFAULT=[]byte(" ELSE "))
   171  		ElseFragment []byte
   172  		// The End keyword to use when when creating a CASE statement (DEFAULT=[]byte(" END"))
   173  		EndFragment []byte
   174  		// The quote rune to use when quoting string literals (DEFAULT='\'')
   175  		StringQuote rune
   176  		// The operator to use when setting values in an update statement (DEFAULT='=')
   177  		SetOperatorRune rune
   178  		// The placeholder fragment to use when generating a non interpolated statement (DEFAULT=[]byte"?")
   179  		PlaceHolderFragment []byte
   180  		// Empty string (DEFAULT="")
   181  		EmptyString string
   182  		// Comma rune (DEFAULT=',')
   183  		CommaRune rune
   184  		// Space rune (DEFAULT=' ')
   185  		SpaceRune rune
   186  		// Left paren rune (DEFAULT='(')
   187  		LeftParenRune rune
   188  		// Right paren rune (DEFAULT=')')
   189  		RightParenRune rune
   190  		// Star rune (DEFAULT='*')
   191  		StarRune rune
   192  		// Period rune (DEFAULT='.')
   193  		PeriodRune rune
   194  		// Set to true to include positional argument numbers when creating a prepared statement (Default=false)
   195  		IncludePlaceholderNum bool
   196  		// The time format to use when serializing time.Time (DEFAULT=time.RFC3339Nano)
   197  		TimeFormat string
   198  		// A map used to look up BooleanOperations and their SQL equivalents
   199  		// (Default= map[exp.BooleanOperation][]byte{
   200  		// 		exp.EqOp:             []byte("="),
   201  		// 		exp.NeqOp:            []byte("!="),
   202  		// 		exp.GtOp:             []byte(">"),
   203  		// 		exp.GteOp:            []byte(">="),
   204  		// 		exp.LtOp:             []byte("<"),
   205  		// 		exp.LteOp:            []byte("<="),
   206  		// 		exp.InOp:             []byte("IN"),
   207  		// 		exp.NotInOp:          []byte("NOT IN"),
   208  		// 		exp.IsOp:             []byte("IS"),
   209  		// 		exp.IsNotOp:          []byte("IS NOT"),
   210  		// 		exp.LikeOp:           []byte("LIKE"),
   211  		// 		exp.NotLikeOp:        []byte("NOT LIKE"),
   212  		// 		exp.ILikeOp:          []byte("ILIKE"),
   213  		// 		exp.NotILikeOp:       []byte("NOT ILIKE"),
   214  		// 		exp.RegexpLikeOp:     []byte("~"),
   215  		// 		exp.RegexpNotLikeOp:  []byte("!~"),
   216  		// 		exp.RegexpILikeOp:    []byte("~*"),
   217  		// 		exp.RegexpNotILikeOp: []byte("!~*"),
   218  		// })
   219  		BooleanOperatorLookup map[exp.BooleanOperation][]byte
   220  		// A map used to look up BitwiseOperations and their SQL equivalents
   221  		// (Default=map[exp.BitwiseOperation][]byte{
   222  		// 		exp.BitwiseInversionOp:  []byte("~"),
   223  		// 		exp.BitwiseOrOp:         []byte("|"),
   224  		// 		exp.BitwiseAndOp:        []byte("&"),
   225  		// 		exp.BitwiseXorOp:        []byte("#"),
   226  		// 		exp.BitwiseLeftShiftOp:  []byte("<<"),
   227  		// 		exp.BitwiseRightShiftOp: []byte(">>"),
   228  		// }),
   229  		BitwiseOperatorLookup map[exp.BitwiseOperation][]byte
   230  		// A map used to look up RangeOperations and their SQL equivalents
   231  		// (Default=map[exp.RangeOperation][]byte{
   232  		// 		exp.BetweenOp:    []byte("BETWEEN"),
   233  		// 		exp.NotBetweenOp: []byte("NOT BETWEEN"),
   234  		// 	})
   235  		RangeOperatorLookup map[exp.RangeOperation][]byte
   236  		// A map used to look up JoinTypes and their SQL equivalents
   237  		// (Default= map[exp.JoinType][]byte{
   238  		// 		exp.InnerJoinType:        []byte(" INNER JOIN "),
   239  		// 		exp.FullOuterJoinType:    []byte(" FULL OUTER JOIN "),
   240  		// 		exp.RightOuterJoinType:   []byte(" RIGHT OUTER JOIN "),
   241  		// 		exp.LeftOuterJoinType:    []byte(" LEFT OUTER JOIN "),
   242  		// 		exp.FullJoinType:         []byte(" FULL JOIN "),
   243  		// 		exp.RightJoinType:        []byte(" RIGHT JOIN "),
   244  		// 		exp.LeftJoinType:         []byte(" LEFT JOIN "),
   245  		// 		exp.NaturalJoinType:      []byte(" NATURAL JOIN "),
   246  		// 		exp.NaturalLeftJoinType:  []byte(" NATURAL LEFT JOIN "),
   247  		// 		exp.NaturalRightJoinType: []byte(" NATURAL RIGHT JOIN "),
   248  		// 		exp.NaturalFullJoinType:  []byte(" NATURAL FULL JOIN "),
   249  		// 		exp.CrossJoinType:        []byte(" CROSS JOIN "),
   250  		// 	})
   251  		JoinTypeLookup map[exp.JoinType][]byte
   252  		// Whether or not boolean data type is supported
   253  		BooleanDataTypeSupported bool
   254  		// Whether or not to use literal TRUE or FALSE for IS statements (e.g. IS TRUE or IS 0)
   255  		UseLiteralIsBools bool
   256  		// EscapedRunes is a map of a rune and the corresponding escape sequence in bytes. Used when escaping text
   257  		// types.
   258  		// (Default= map[rune][]byte{
   259  		// 		'\'': []byte("''"),
   260  		// 	})
   261  		EscapedRunes map[rune][]byte
   262  
   263  		// The SQL fragment to use for CONFLICT (Default=[]byte(" ON CONFLICT"))
   264  		ConflictFragment []byte
   265  		// The SQL fragment to use for CONFLICT DO NOTHING (Default=[]byte(" DO NOTHING"))
   266  		ConflictDoNothingFragment []byte
   267  		// The SQL fragment to use for CONFLICT DO UPDATE (Default=[]byte(" DO UPDATE SET"))
   268  		ConflictDoUpdateFragment []byte
   269  
   270  		// The order of SQL fragments when creating a SELECT statement
   271  		// (Default=[]SQLFragmentType{
   272  		// 		CommonTableSQLFragment,
   273  		// 		SelectSQLFragment,
   274  		// 		FromSQLFragment,
   275  		// 		JoinSQLFragment,
   276  		// 		WhereSQLFragment,
   277  		// 		GroupBySQLFragment,
   278  		// 		HavingSQLFragment,
   279  		// 		CompoundsSQLFragment,
   280  		// 		OrderSQLFragment,
   281  		// 		LimitSQLFragment,
   282  		// 		OffsetSQLFragment,
   283  		// 		ForSQLFragment,
   284  		// 	})
   285  		SelectSQLOrder []SQLFragmentType
   286  
   287  		// The order of SQL fragments when creating an UPDATE statement
   288  		// (Default=[]SQLFragmentType{
   289  		// 		CommonTableSQLFragment,
   290  		// 		UpdateBeginSQLFragment,
   291  		// 		SourcesSQLFragment,
   292  		// 		UpdateSQLFragment,
   293  		// 		WhereSQLFragment,
   294  		// 		OrderSQLFragment,
   295  		// 		LimitSQLFragment,
   296  		// 		ReturningSQLFragment,
   297  		// 	})
   298  		UpdateSQLOrder []SQLFragmentType
   299  
   300  		// The order of SQL fragments when creating an INSERT statement
   301  		// (Default=[]SQLFragmentType{
   302  		// 		CommonTableSQLFragment,
   303  		// 		InsertBeingSQLFragment,
   304  		// 		SourcesSQLFragment,
   305  		// 		InsertSQLFragment,
   306  		// 		ReturningSQLFragment,
   307  		// 	})
   308  		InsertSQLOrder []SQLFragmentType
   309  
   310  		// The order of SQL fragments when creating a DELETE statement
   311  		// (Default=[]SQLFragmentType{
   312  		// 		CommonTableSQLFragment,
   313  		// 		DeleteBeginSQLFragment,
   314  		// 		FromSQLFragment,
   315  		// 		WhereSQLFragment,
   316  		// 		OrderSQLFragment,
   317  		// 		LimitSQLFragment,
   318  		// 		ReturningSQLFragment,
   319  		// 	})
   320  		DeleteSQLOrder []SQLFragmentType
   321  
   322  		// The order of SQL fragments when creating a TRUNCATE statement
   323  		// (Default=[]SQLFragmentType{
   324  		// 		TruncateSQLFragment,
   325  		// 	})
   326  		TruncateSQLOrder []SQLFragmentType
   327  	}
   328  )
   329  
   330  const (
   331  	CommonTableSQLFragment = iota
   332  	SelectSQLFragment
   333  	SelectWithLimitSQLFragment
   334  	FromSQLFragment
   335  	JoinSQLFragment
   336  	WhereSQLFragment
   337  	GroupBySQLFragment
   338  	HavingSQLFragment
   339  	CompoundsSQLFragment
   340  	OrderSQLFragment
   341  	OrderWithOffsetFetchSQLFragment
   342  	LimitSQLFragment
   343  	OffsetSQLFragment
   344  	ForSQLFragment
   345  	UpdateBeginSQLFragment
   346  	SourcesSQLFragment
   347  	IntoSQLFragment
   348  	UpdateSQLFragment
   349  	UpdateFromSQLFragment
   350  	ReturningSQLFragment
   351  	InsertBeingSQLFragment
   352  	InsertSQLFragment
   353  	DeleteBeginSQLFragment
   354  	TruncateSQLFragment
   355  	WindowSQLFragment
   356  )
   357  
   358  // nolint:gocyclo // simple type to string conversion
   359  func (sf SQLFragmentType) String() string {
   360  	switch sf {
   361  	case CommonTableSQLFragment:
   362  		return "CommonTableSQLFragment"
   363  	case SelectSQLFragment:
   364  		return "SelectSQLFragment"
   365  	case FromSQLFragment:
   366  		return "FromSQLFragment"
   367  	case JoinSQLFragment:
   368  		return "JoinSQLFragment"
   369  	case WhereSQLFragment:
   370  		return "WhereSQLFragment"
   371  	case GroupBySQLFragment:
   372  		return "GroupBySQLFragment"
   373  	case HavingSQLFragment:
   374  		return "HavingSQLFragment"
   375  	case CompoundsSQLFragment:
   376  		return "CompoundsSQLFragment"
   377  	case OrderSQLFragment:
   378  		return "OrderSQLFragment"
   379  	case LimitSQLFragment:
   380  		return "LimitSQLFragment"
   381  	case OffsetSQLFragment:
   382  		return "OffsetSQLFragment"
   383  	case ForSQLFragment:
   384  		return "ForSQLFragment"
   385  	case UpdateBeginSQLFragment:
   386  		return "UpdateBeginSQLFragment"
   387  	case SourcesSQLFragment:
   388  		return "SourcesSQLFragment"
   389  	case IntoSQLFragment:
   390  		return "IntoSQLFragment"
   391  	case UpdateSQLFragment:
   392  		return "UpdateSQLFragment"
   393  	case UpdateFromSQLFragment:
   394  		return "UpdateFromSQLFragment"
   395  	case ReturningSQLFragment:
   396  		return "ReturningSQLFragment"
   397  	case InsertBeingSQLFragment:
   398  		return "InsertBeingSQLFragment"
   399  	case DeleteBeginSQLFragment:
   400  		return "DeleteBeginSQLFragment"
   401  	case TruncateSQLFragment:
   402  		return "TruncateSQLFragment"
   403  	case WindowSQLFragment:
   404  		return "WindowSQLFragment"
   405  	}
   406  	return fmt.Sprintf("%d", sf)
   407  }
   408  
   409  //nolint:funlen
   410  func DefaultDialectOptions() *SQLDialectOptions {
   411  	return &SQLDialectOptions{
   412  		SupportsOrderByOnDelete:     false,
   413  		SupportsDeleteTableHint:     false,
   414  		SupportsOrderByOnUpdate:     false,
   415  		SupportsLimitOnDelete:       false,
   416  		SupportsLimitOnUpdate:       false,
   417  		SupportsReturn:              true,
   418  		SupportsConflictUpdateWhere: true,
   419  		SupportsInsertIgnoreSyntax:  false,
   420  		SupportsConflictTarget:      true,
   421  		SupportsWithCTE:             true,
   422  		SupportsWithCTERecursive:    true,
   423  		SupportsDistinctOn:          true,
   424  		WrapCompoundsInParens:       true,
   425  		SupportsWindowFunction:      true,
   426  		SupportsLateral:             true,
   427  
   428  		SupportsMultipleUpdateTables:         true,
   429  		UseFromClauseForMultipleUpdateTables: true,
   430  
   431  		UpdateClause:              []byte("UPDATE"),
   432  		InsertClause:              []byte("INSERT INTO"),
   433  		InsertIgnoreClause:        []byte("INSERT IGNORE INTO"),
   434  		SelectClause:              []byte("SELECT"),
   435  		DeleteClause:              []byte("DELETE"),
   436  		TruncateClause:            []byte("TRUNCATE"),
   437  		WithFragment:              []byte("WITH "),
   438  		RecursiveFragment:         []byte("RECURSIVE "),
   439  		CascadeFragment:           []byte(" CASCADE"),
   440  		RestrictFragment:          []byte(" RESTRICT"),
   441  		DefaultValuesFragment:     []byte(" DEFAULT VALUES"),
   442  		ValuesFragment:            []byte(" VALUES "),
   443  		IdentityFragment:          []byte(" IDENTITY"),
   444  		SetFragment:               []byte(" SET "),
   445  		DistinctFragment:          []byte("DISTINCT"),
   446  		ReturningFragment:         []byte(" RETURNING "),
   447  		FromFragment:              []byte(" FROM"),
   448  		UsingFragment:             []byte(" USING "),
   449  		OnFragment:                []byte(" ON "),
   450  		WhereFragment:             []byte(" WHERE "),
   451  		GroupByFragment:           []byte(" GROUP BY "),
   452  		HavingFragment:            []byte(" HAVING "),
   453  		WindowFragment:            []byte(" WINDOW "),
   454  		WindowPartitionByFragment: []byte("PARTITION BY "),
   455  		WindowOrderByFragment:     []byte("ORDER BY "),
   456  		WindowOverFragment:        []byte(" OVER "),
   457  		OrderByFragment:           []byte(" ORDER BY "),
   458  		FetchFragment:             []byte(" "),
   459  		LimitFragment:             []byte(" LIMIT "),
   460  		OffsetFragment:            []byte(" OFFSET "),
   461  		ForUpdateFragment:         []byte(" FOR UPDATE "),
   462  		ForNoKeyUpdateFragment:    []byte(" FOR NO KEY UPDATE "),
   463  		ForShareFragment:          []byte(" FOR SHARE "),
   464  		ForKeyShareFragment:       []byte(" FOR KEY SHARE "),
   465  		OfFragment:                []byte("OF "),
   466  		NowaitFragment:            []byte("NOWAIT"),
   467  		SkipLockedFragment:        []byte("SKIP LOCKED"),
   468  		LateralFragment:           []byte("LATERAL "),
   469  		AsFragment:                []byte(" AS "),
   470  		AscFragment:               []byte(" ASC"),
   471  		DescFragment:              []byte(" DESC"),
   472  		NullsFirstFragment:        []byte(" NULLS FIRST"),
   473  		NullsLastFragment:         []byte(" NULLS LAST"),
   474  		AndFragment:               []byte(" AND "),
   475  		OrFragment:                []byte(" OR "),
   476  		UnionFragment:             []byte(" UNION "),
   477  		UnionAllFragment:          []byte(" UNION ALL "),
   478  		IntersectFragment:         []byte(" INTERSECT "),
   479  		IntersectAllFragment:      []byte(" INTERSECT ALL "),
   480  		ConflictFragment:          []byte(" ON CONFLICT"),
   481  		ConflictDoUpdateFragment:  []byte(" DO UPDATE SET "),
   482  		ConflictDoNothingFragment: []byte(" DO NOTHING"),
   483  		CastFragment:              []byte("CAST"),
   484  		CaseFragment:              []byte("CASE "),
   485  		WhenFragment:              []byte(" WHEN "),
   486  		ThenFragment:              []byte(" THEN "),
   487  		ElseFragment:              []byte(" ELSE "),
   488  		EndFragment:               []byte(" END"),
   489  		Null:                      []byte("NULL"),
   490  		True:                      []byte("TRUE"),
   491  		False:                     []byte("FALSE"),
   492  
   493  		PlaceHolderFragment: []byte("?"),
   494  		QuoteRune:           '"',
   495  		StringQuote:         '\'',
   496  		SetOperatorRune:     '=',
   497  		CommaRune:           ',',
   498  		SpaceRune:           ' ',
   499  		LeftParenRune:       '(',
   500  		RightParenRune:      ')',
   501  		StarRune:            '*',
   502  		PeriodRune:          '.',
   503  		EmptyString:         "",
   504  
   505  		BooleanOperatorLookup: map[exp.BooleanOperation][]byte{
   506  			exp.EqOp:             []byte("="),
   507  			exp.NeqOp:            []byte("!="),
   508  			exp.GtOp:             []byte(">"),
   509  			exp.GteOp:            []byte(">="),
   510  			exp.LtOp:             []byte("<"),
   511  			exp.LteOp:            []byte("<="),
   512  			exp.InOp:             []byte("IN"),
   513  			exp.NotInOp:          []byte("NOT IN"),
   514  			exp.IsOp:             []byte("IS"),
   515  			exp.IsNotOp:          []byte("IS NOT"),
   516  			exp.LikeOp:           []byte("LIKE"),
   517  			exp.NotLikeOp:        []byte("NOT LIKE"),
   518  			exp.ILikeOp:          []byte("ILIKE"),
   519  			exp.NotILikeOp:       []byte("NOT ILIKE"),
   520  			exp.RegexpLikeOp:     []byte("~"),
   521  			exp.RegexpNotLikeOp:  []byte("!~"),
   522  			exp.RegexpILikeOp:    []byte("~*"),
   523  			exp.RegexpNotILikeOp: []byte("!~*"),
   524  		},
   525  		BitwiseOperatorLookup: map[exp.BitwiseOperation][]byte{
   526  			exp.BitwiseInversionOp:  []byte("~"),
   527  			exp.BitwiseOrOp:         []byte("|"),
   528  			exp.BitwiseAndOp:        []byte("&"),
   529  			exp.BitwiseXorOp:        []byte("#"),
   530  			exp.BitwiseLeftShiftOp:  []byte("<<"),
   531  			exp.BitwiseRightShiftOp: []byte(">>"),
   532  		},
   533  		RangeOperatorLookup: map[exp.RangeOperation][]byte{
   534  			exp.BetweenOp:    []byte("BETWEEN"),
   535  			exp.NotBetweenOp: []byte("NOT BETWEEN"),
   536  		},
   537  		JoinTypeLookup: map[exp.JoinType][]byte{
   538  			exp.InnerJoinType:        []byte(" INNER JOIN "),
   539  			exp.FullOuterJoinType:    []byte(" FULL OUTER JOIN "),
   540  			exp.RightOuterJoinType:   []byte(" RIGHT OUTER JOIN "),
   541  			exp.LeftOuterJoinType:    []byte(" LEFT OUTER JOIN "),
   542  			exp.FullJoinType:         []byte(" FULL JOIN "),
   543  			exp.RightJoinType:        []byte(" RIGHT JOIN "),
   544  			exp.LeftJoinType:         []byte(" LEFT JOIN "),
   545  			exp.NaturalJoinType:      []byte(" NATURAL JOIN "),
   546  			exp.NaturalLeftJoinType:  []byte(" NATURAL LEFT JOIN "),
   547  			exp.NaturalRightJoinType: []byte(" NATURAL RIGHT JOIN "),
   548  			exp.NaturalFullJoinType:  []byte(" NATURAL FULL JOIN "),
   549  			exp.CrossJoinType:        []byte(" CROSS JOIN "),
   550  		},
   551  
   552  		TimeFormat: time.RFC3339Nano,
   553  
   554  		BooleanDataTypeSupported: true,
   555  		UseLiteralIsBools:        true,
   556  
   557  		EscapedRunes: map[rune][]byte{
   558  			'\'': []byte("''"),
   559  		},
   560  
   561  		SelectSQLOrder: []SQLFragmentType{
   562  			CommonTableSQLFragment,
   563  			SelectSQLFragment,
   564  			FromSQLFragment,
   565  			JoinSQLFragment,
   566  			WhereSQLFragment,
   567  			GroupBySQLFragment,
   568  			HavingSQLFragment,
   569  			WindowSQLFragment,
   570  			CompoundsSQLFragment,
   571  			OrderSQLFragment,
   572  			LimitSQLFragment,
   573  			OffsetSQLFragment,
   574  			ForSQLFragment,
   575  		},
   576  		UpdateSQLOrder: []SQLFragmentType{
   577  			CommonTableSQLFragment,
   578  			UpdateBeginSQLFragment,
   579  			SourcesSQLFragment,
   580  			UpdateSQLFragment,
   581  			UpdateFromSQLFragment,
   582  			WhereSQLFragment,
   583  			OrderSQLFragment,
   584  			LimitSQLFragment,
   585  			ReturningSQLFragment,
   586  		},
   587  		InsertSQLOrder: []SQLFragmentType{
   588  			CommonTableSQLFragment,
   589  			InsertBeingSQLFragment,
   590  			IntoSQLFragment,
   591  			InsertSQLFragment,
   592  			ReturningSQLFragment,
   593  		},
   594  		DeleteSQLOrder: []SQLFragmentType{
   595  			CommonTableSQLFragment,
   596  			DeleteBeginSQLFragment,
   597  			FromSQLFragment,
   598  			WhereSQLFragment,
   599  			OrderSQLFragment,
   600  			LimitSQLFragment,
   601  			ReturningSQLFragment,
   602  		},
   603  		TruncateSQLOrder: []SQLFragmentType{
   604  			TruncateSQLFragment,
   605  		},
   606  	}
   607  }
   608  

View as plain text