.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "SQL::Abstract::Tree 3pm" .TH SQL::Abstract::Tree 3pm "2021-09-30" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SQL::Abstract::Tree \- Represent SQL as an AST .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& my $sqla_tree = SQL::Abstract::Tree\->new({ profile => \*(Aqconsole\*(Aq }); \& \& print $sqla_tree\->format(\*(AqSELECT * FROM foo WHERE foo.a > 2\*(Aq); \& \& # SELECT * \& # FROM foo \& # WHERE foo.a > 2 .Ve .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" .Vb 1 \& my $sqla_tree = SQL::Abstract::Tree\->new({ profile => \*(Aqconsole\*(Aq }); \& \& $args = { \& profile => \*(Aqconsole\*(Aq, # predefined profile to use (default: \*(Aqnone\*(Aq) \& fill_in_placeholders => 1, # true for placeholder population \& placeholder_surround => # The strings that will be wrapped around \& [GREEN, RESET], # populated placeholders if the above is set \& indent_string => \*(Aq \*(Aq, # the string used when indenting \& indent_amount => 2, # how many of above string to use for a single \& # indent level \& newline => "\en", # string for newline \& colormap => { \& select => [RED, RESET], # a pair of strings defining what to surround \& # the keyword with for colorization \& # ... \& }, \& indentmap => { \& select => 0, # A zero means that the keyword will start on \& # a new line \& from => 1, # Any other positive integer means that after \& on => 2, # said newline it will get that many indents \& # ... \& }, \& } .Ve .PP Returns a new SQL::Abstract::Tree object. All arguments are optional. .PP \fIprofiles\fR .IX Subsection "profiles" .PP There are four predefined profiles, \f(CW\*(C`none\*(C'\fR, \f(CW\*(C`console\*(C'\fR, \f(CW\*(C`console_monochrome\*(C'\fR, and \f(CW\*(C`html\*(C'\fR. Typically a user will probably just use \f(CW\*(C`console\*(C'\fR or \&\f(CW\*(C`console_monochrome\*(C'\fR, but if something about a profile bothers you, merely use the profile and override the parts that you don't like. .SS "format" .IX Subsection "format" .Vb 1 \& $sqlat\->format(\*(AqSELECT * FROM bar WHERE x = ?\*(Aq, [1]) .Ve .PP Takes \f(CW$sql\fR and \f(CW\*(C`\e@bindargs\*(C'\fR. .PP Returns a formatting string based on the string passed in .SS "parse" .IX Subsection "parse" .Vb 1 \& $sqlat\->parse(\*(AqSELECT * FROM bar WHERE x = ?\*(Aq) .Ve .PP Returns a \*(L"tree\*(R" representing passed in \s-1SQL.\s0 Please do not depend on the structure of the returned tree. It may be stable at some point, but not yet. .SS "unparse" .IX Subsection "unparse" .Vb 1 \& $sqlat\->unparse($tree_structure, \e@bindargs) .Ve .PP Transform \*(L"tree\*(R" into \s-1SQL,\s0 applying various transforms on the way. .SS "format_keyword" .IX Subsection "format_keyword" .Vb 1 \& $sqlat\->format_keyword(\*(AqSELECT\*(Aq) .Ve .PP Currently this just takes a keyword and puts the \f(CW\*(C`colormap\*(C'\fR stuff around it. Later on it may do more and allow for coderef based transforms. .SS "pad_keyword" .IX Subsection "pad_keyword" .Vb 1 \& my ($before, $after) = @{$sqlat\->pad_keyword(\*(AqSELECT\*(Aq)}; .Ve .PP Returns whitespace to be inserted around a keyword. .SS "fill_in_placeholder" .IX Subsection "fill_in_placeholder" .Vb 1 \& my $value = $sqlat\->fill_in_placeholder(\e@bindargs) .Ve .PP Removes last arg from passed arrayref and returns it, surrounded with the values in placeholder_surround, and then surrounded with single quotes. .SS "indent" .IX Subsection "indent" Returns as many indent strings as indent amounts times the first argument. .SH "ACCESSORS" .IX Header "ACCESSORS" .SS "colormap" .IX Subsection "colormap" See \*(L"new\*(R" .SS "fill_in_placeholders" .IX Subsection "fill_in_placeholders" See \*(L"new\*(R" .SS "indent_amount" .IX Subsection "indent_amount" See \*(L"new\*(R" .SS "indent_string" .IX Subsection "indent_string" See \*(L"new\*(R" .SS "indentmap" .IX Subsection "indentmap" See \*(L"new\*(R" .SS "newline" .IX Subsection "newline" See \*(L"new\*(R" .SS "placeholder_surround" .IX Subsection "placeholder_surround" See \*(L"new\*(R"