1- use super :: node_list:: emit_comma_separated_list;
21use crate :: {
32 TokenKind ,
43 emitter:: { EventEmitter , GroupKind , LineType } ,
54} ;
6- use pgls_query:: protobuf:: CreateExtensionStmt ;
5+ use pgls_query:: { NodeEnum , protobuf:: CreateExtensionStmt } ;
76
87pub ( super ) fn emit_create_extension_stmt ( e : & mut EventEmitter , n : & CreateExtensionStmt ) {
98 e. group_start ( GroupKind :: CreateExtensionStmt ) ;
@@ -27,11 +26,57 @@ pub(super) fn emit_create_extension_stmt(e: &mut EventEmitter, n: &CreateExtensi
2726 if !n. options . is_empty ( ) {
2827 e. line ( LineType :: SoftOrSpace ) ;
2928 e. token ( TokenKind :: WITH_KW ) ;
30- e. space ( ) ;
31- emit_comma_separated_list ( e, & n. options , super :: emit_node) ;
29+
30+ for opt in & n. options {
31+ let def = assert_node_variant ! ( DefElem , opt) ;
32+ e. space ( ) ;
33+ emit_extension_option ( e, def) ;
34+ }
3235 }
3336
3437 e. token ( TokenKind :: SEMICOLON ) ;
3538
3639 e. group_end ( ) ;
3740}
41+
42+ /// Emit a CREATE EXTENSION option.
43+ /// Options use keyword syntax (no equals sign):
44+ /// SCHEMA schema_name
45+ /// VERSION 'version'
46+ /// CASCADE
47+ fn emit_extension_option ( e : & mut EventEmitter , def : & pgls_query:: protobuf:: DefElem ) {
48+ match def. defname . as_str ( ) {
49+ "schema" => {
50+ e. token ( TokenKind :: SCHEMA_KW ) ;
51+ if let Some ( ref arg) = def. arg {
52+ e. space ( ) ;
53+ // Schema name is a String node - emit_node dispatches to
54+ // emit_string which uses emit_identifier_maybe_quoted
55+ super :: emit_node ( arg, e) ;
56+ }
57+ }
58+ "new_version" => {
59+ e. token ( TokenKind :: VERSION_KW ) ;
60+ if let Some ( ref arg) = def. arg {
61+ e. space ( ) ;
62+ // Version must be a quoted string literal
63+ if let Some ( NodeEnum :: String ( s) ) = & arg. node {
64+ super :: emit_string_literal ( e, s) ;
65+ } else {
66+ super :: emit_node ( arg, e) ;
67+ }
68+ }
69+ }
70+ "cascade" => {
71+ e. token ( TokenKind :: CASCADE_KW ) ;
72+ }
73+ _ => {
74+ // Fallback for unknown options
75+ super :: string:: emit_keyword ( e, & def. defname ) ;
76+ if let Some ( ref arg) = def. arg {
77+ e. space ( ) ;
78+ super :: emit_node ( arg, e) ;
79+ }
80+ }
81+ }
82+ }
0 commit comments