@@ -23,6 +23,7 @@ import {
23
23
isCompoundSelectStmt ,
24
24
} from "../node_utils" ;
25
25
import { isString , last } from "../utils" ;
26
+ import { AllPrettierOptions } from "src/options" ;
26
27
27
28
export const exprMap : CstToDocMap < AllExprNodes > = {
28
29
list_expr : ( print , node , path ) => {
@@ -169,13 +170,15 @@ export const exprMap: CstToDocMap<AllExprNodes> = {
169
170
/** cst-ignore: value */
170
171
number_literal : ( print ) => print ( "text" ) ,
171
172
/** cst-ignore: value */
172
- boolean_literal : ( print ) => print ( "valueKw" ) ,
173
+ boolean_literal : ( print , node , path , options ) =>
174
+ printLiteral ( node . valueKw , options ) ,
173
175
/** cst-ignore: value */
174
176
string_literal : ( print ) => print ( "text" ) ,
175
177
/** cst-ignore: value */
176
178
blob_literal : ( print ) => print ( "text" ) ,
177
179
/** cst-ignore: value */
178
- null_literal : ( print ) => print ( "nullKw" ) ,
180
+ null_literal : ( print , node , path , options ) =>
181
+ printLiteral ( node . nullKw , options ) ,
179
182
numeric_literal : ( print ) => print . spaced ( [ "numericKw" , "string" ] ) ,
180
183
bignumeric_literal : ( print ) => print . spaced ( [ "bignumericKw" , "string" ] ) ,
181
184
date_literal : ( print ) => print . spaced ( [ "dateKw" , "string" ] ) ,
@@ -191,4 +194,15 @@ export const exprMap: CstToDocMap<AllExprNodes> = {
191
194
parameter : ( print ) => print ( "text" ) ,
192
195
} ;
193
196
197
+ const printLiteral = < T > ( node : Keyword , options : AllPrettierOptions < T > ) => {
198
+ switch ( options . sqlLiteralCase ) {
199
+ case "preserve" :
200
+ return node . text ;
201
+ case "upper" :
202
+ return node . text . toUpperCase ( ) ;
203
+ case "lower" :
204
+ return node . text . toLowerCase ( ) ;
205
+ }
206
+ } ;
207
+
194
208
const isBooleanOp = ( { name } : Keyword ) => name === "AND" || name === "OR" ;
0 commit comments