From 2bba7ea620cc6c257238d250690dc903d28ade95 Mon Sep 17 00:00:00 2001
From: Sabra Crolleton Table of Contents
is all that is needed to produce the final SQL query.
→ string @@ -483,8 +483,8 @@
→ string @@ -516,8 +516,8 @@
In cases where you do need to build the query at run time, yet you do not @@ -530,8 +530,8 @@
Modifies the current readtable to add a #Q syntax that is read as (sql …). @@ -539,8 +539,8 @@
→ string @@ -559,8 +559,8 @@
→ string @@ -586,16 +586,16 @@
When converting symbols to strings, whether to downcase the symbols is set here. The default is to downcase symbols.
Used to configure whether S-SQL will use standard SQL strings (just replace #\' with ''), or backslash-style escaping. Setting this to NIL is always safe, but when the server is configured to allow standard strings (compile-time parameter 'standard_conforming_strings' is 'on', which will become the default in future versions of PostgreSQL), the noise in queries can be reduced by setting this to T. @@ -603,8 +603,8 @@
A set of all Postgresql's reserved words, for automatic escaping. Probably not a good idea to use these words as identifiers anyway. @@ -623,8 +623,8 @@
Determines whether double quotes are added around column, table, and ** function names in @@ -651,8 +651,8 @@
→ string @@ -664,8 +664,8 @@
→ string @@ -681,8 +681,8 @@
→ keyword @@ -695,8 +695,8 @@
Define simple SQL operators. Arity is one of :unary (like 'not'), :unary-postfix @@ -710,8 +710,8 @@
S-SQL knows the SQL equivalents to a number of Lisp types, and defines some @@ -831,8 +831,8 @@
This is a type of which only the keyword :null is a member. It is used to represent @@ -842,8 +842,8 @@
An S-SQL form is converted to a query through the following rules: @@ -864,8 +864,8 @@
Creates a select query. The arguments are split on the keywords found among @@ -912,12 +912,12 @@
From the postgresql documentation: "For every possible combination of rows from T1 and T2 (i.e., a Cartesian product), the joined table will contain a row consisting of all columns in T1 followed by all columns in T2. If the tables have N and M rows respectively, the joined table will have N * M rows." @@ -929,8 +929,8 @@
An inner join looks at two tables and creates a new result consisting of the selected elements in the rows from the two tables that match the specified conditions. You can simplistically think of it as the intersection of the two sets. In reality, it is creating a new set consisting of certain elements of the intersecting rows. An inner join is the default and need not be specified. @@ -999,8 +999,8 @@
An outer join not only generates an inner join, it also joins the rows from one table that matches the conditions and adds null values for the joined columns from the second table (which obviously did not match the condition.) Under Postgresql, a "left join", "right join" or "full join" all imply an outer join. @@ -1012,8 +1012,8 @@
Example: Here we assume two tables. A countries table and a many-to-many linking table named countries-topics. (There is an implicit third table named topics.) We are looking for records from the countries table which do not have a match in the countries-topics table. In other words, where do we have a note, but not matched it to a topic? @@ -1048,16 +1048,16 @@
The following operators are defined:
These are expanded as infix operators. When meaningful, they allow more than @@ -1073,8 +1073,8 @@
Unary operators for bitwise and logical negation. @@ -1194,8 +1194,8 @@
Any needs to be considered as a special case. Quoting Marijn Haverbeke here,"Postgres has both a function-call-style any and an infix any, and S-SQL's syntax doesn't allow them to be distinguished." As a result, postmodern has a regular :any sql-op and a :any* sql-op, which expand slightly differently. @@ -1303,8 +1303,8 @@
Create a stored procedure. The argument and return types are interpreted as @@ -1319,8 +1319,8 @@
Regular expression matching operators. The exclamation mark means 'does not match', @@ -1366,8 +1366,8 @@
Simple SQL string matching operators (:ilike is case-insensitive). @@ -1380,8 +1380,8 @@
Fast Text Search match operator. @@ -1389,8 +1389,8 @@
Used to invert the meaning of an operator in an :order-by clause. @@ -1405,8 +1405,8 @@
Used to determine where :null values appear in an :order-by clause. @@ -1414,8 +1414,8 @@
Also known in some explanations as "alias". This assigns a name to a column or @@ -1470,8 +1470,8 @@
The CAST operator. Takes a query as an argument, and returns the result @@ -1500,8 +1500,8 @@
Is similar to cast but uses the postgresql :: formating. Unlike cast it will not @@ -1519,8 +1519,8 @@
Creates a composite type with a type-name and two or more columns. E.g. @@ -1531,8 +1531,8 @@
The EXISTS operator. Takes a query as an argument, and returns true or false @@ -1552,8 +1552,8 @@
Test whether a value is null. @@ -1564,8 +1564,8 @@
Test whether a value is not null. @@ -1576,8 +1576,8 @@
Test whether a value is in a set of values. @@ -1597,8 +1597,8 @@
Inverse of the above. @@ -1606,8 +1606,8 @@
Denote a set of values. This operator has two interfaces. When @@ -1682,8 +1682,8 @@
This is used when calling a select query into an array. See array-notes.html @@ -1708,8 +1708,8 @@
This is the general operator for arrays. It also handles statements that include @@ -1730,8 +1730,8 @@
Dereference an array value. If end is provided, extract a slice of the array. @@ -1747,8 +1747,8 @@
Extract a field from a date/time value. For example, (:extract :month (:now)). @@ -1767,8 +1767,8 @@
A conditional expression. Clauses should take the form (test value). If @@ -1783,8 +1783,8 @@
Test whether a value lies between two other values. @@ -1798,8 +1798,8 @@
Works like :between, except that the start value is not required to be @@ -1808,8 +1808,8 @@
Can be used to combine multiple names into a name of the form A.B to @@ -1819,8 +1819,8 @@
Add a type declaration to a value, as in in "4.3::real". The second @@ -1833,8 +1833,8 @@
Insert a string as-is into the query. This can be useful for doing things @@ -1851,8 +1851,8 @@
Fetch is a more efficient way to do pagination instead of using limit and @@ -1879,8 +1879,8 @@
In S-SQL limit is not part of the select operator, but an extra @@ -1896,8 +1896,8 @@
Order the results of a query by the given expressions. See :desc for @@ -1914,8 +1914,8 @@
Values computes a row value or set of row values for use in a specific @@ -1950,8 +1950,8 @@
This is a fudge. It returns a string "()" where something like '() @@ -1967,8 +1967,8 @@
https://www.postgresql.org/docs/current/static/queries-table-expressions.html#QUERIES-GROUPING-SETS @@ -1993,8 +1993,8 @@
https://www.postgresql.org/docs/current/static/queries-table-expressions.html#QUERIES-GROUPING-SETS @@ -2014,20 +2014,20 @@
Creates an interval data type, generally represented in postmodern as an alist
(query (:select (:current-date)) :single) @@ -2035,33 +2035,33 @@-
sql-op :current-time ()
+ --sql-op :current-timestamp ()
+ --sql-op :timestamp (arg)
+ --sql-op :age (&rest args)
+ --sql-op :date (arg)
+ --sql-op :make-interval (&rest args)
++sql-op :make-interval (&rest args)
Takes lists of (time-unit value) and returns a timestamp type. Example: @@ -2074,8 +2074,8 @@
-
sql-op :make-timestamp (&rest args)
++sql-op :make-timestamp (&rest args)
Takes lists of (time-unit value) and returns a timestamptz type. Example: @@ -2089,8 +2089,8 @@
-
sql-op :make-timestamptz (&rest args)
++sql-op :make-timestamptz (&rest args)
Takes lists of (time-unit value) and returns a timestamptz type. Example: @@ -2106,12 +2106,12 @@
-
Aggregation Operators
+