6.2 plisqin-lib/unsafe🔗ℹ
Link to this section with
@secref["plisqin-lib_unsafe"
#:doc '(lib "plisqin-doc/scribblings/plisqin.scrbl")]
Link to this section with
@secref["plisqin-lib_unsafe"
#:doc '(lib "plisqin-doc/scribblings/plisqin.scrbl")]
A primitive building block with no
strict counterpart.
Constructs an arbitrary fragment of SQL that represents an aggregate operation.
This fragment will recognize grouped joins like the built-in aggregates, such
as
%%count or
%%max.
Let’s show the maximum UnitPriceDiscount we’ve ever given for each Product,
and add 42 just for fun:
> (aw:show-table |
(from p Product |
(join detailsG SalesOrderDetail |
(group-by (ProductID detailsG)) |
(join-on (.= (ProductID detailsG) |
(ProductID p)))) |
(select (ProductName p)) |
(select (%%max-plus-42 (UnitPriceDiscount detailsG))) |
(limit 3))) |
Show TableShow SQL | select p.Name as ProductName | , detailsG.__INJECT1 | from Product p | inner join ( | select detailsG.ProductID as __INJECT0 | , max(detailsG.UnitPriceDiscount) + 42 as __INJECT1 | from SalesOrderDetail detailsG | group by detailsG.ProductID | ) detailsG | on (detailsG.__INJECT0 = p.ProductID) | limit 3 |
|
| ProductName | __INJECT1 | Sport-100 Helmet, Red | 42.15 | Sport-100 Helmet, Black | 42.15 | Mountain Bike Socks, M | 42.1 |
|
|
A primitive building block with no
strict counterpart.
Constructs an arbitrary fragment of SQL that represents a scalar.
This fragment will be injected into a grouped join if needed.
In the example on
%%aggregate, notice that
(ProductID detailsG) occurs in a join-on clause of a grouped join.
This is why it appears as "__INJECT0" in the generated SQL.
This behavior is enabled because
(ProductID detailsG) is returning
a
%%scalar.
Although every
%%scalar should be a
Scalar?,
the type
Scalar? is irrelevant to this behavior.
A primitive building block with no
strict counterpart.
Constructs an arbitrary fragment of SQL with no special behavior.
Converts a Racket value into a
Token?.
The token’s
nullability is always
no.
If
type is
#f, it is inferred as follows:
If type is not #f, the return value will be cast to it:
(?? token-1 [token-N ...+] [/fallback])
|
|
|
This procedure is typically used to attach a
fallback, but it can also be
used as a synonym for
%%coalesce if no fallback is given.
More precisely, this procedure has 3 cases:
When given two arguments and the last argument is a
fallback?,
it simply attaches the fallback to the first argument:
(?? token-1 /fallback) |
; is equivalent to |
(>> token-1 #:fallback /fallback) |
When given more than two arguments and the last argument is a
fallback?,
it attaches the fallback to the result of
%%coalesce:
(?? token-1 token-N ...+ /fallback) |
; is equivalent to |
(>> (%%coalesce token-1 token-N ...+) #:fallback /fallback) |
(?? token-1 token-N ...+) |
; is equivalent to |
(%%coalesce token-1 token-N ...+) |
You may need to check the documentation on %%coalesce to know the return
type of cases 2 and 3.
6.2.1 Clauses🔗ℹ
Link to this section with
@secref["plisqin-lib/unsafe/Clauses"
#:doc '(lib "plisqin-doc/scribblings/plisqin.scrbl")]
Link to this section with
@secref["plisqin-lib/unsafe/Clauses"
#:doc '(lib "plisqin-doc/scribblings/plisqin.scrbl")]
6.2.2 Aggregates🔗ℹ
Link to this section with
@secref["plisqin-lib/unsafe/Aggregates"
#:doc '(lib "plisqin-doc/scribblings/plisqin.scrbl")]
Link to this section with
@secref["plisqin-lib/unsafe/Aggregates"
#:doc '(lib "plisqin-doc/scribblings/plisqin.scrbl")]
6.2.3 Misc🔗ℹ
Link to this section with
@secref["plisqin-lib/unsafe/Misc"
#:doc '(lib "plisqin-doc/scribblings/plisqin.scrbl")]
Link to this section with
@secref["plisqin-lib/unsafe/Misc"
#:doc '(lib "plisqin-doc/scribblings/plisqin.scrbl")]
6.2.4 Date Math🔗ℹ
Link to this section with
@secref["plisqin-lib/unsafe/Date Math"
#:doc '(lib "plisqin-doc/scribblings/plisqin.scrbl")]
Link to this section with
@secref["plisqin-lib/unsafe/Date Math"
#:doc '(lib "plisqin-doc/scribblings/plisqin.scrbl")]
6.2.5 Operators🔗ℹ
Link to this section with
@secref["plisqin-lib/unsafe/Operators"
#:doc '(lib "plisqin-doc/scribblings/plisqin.scrbl")]
Link to this section with
@secref["plisqin-lib/unsafe/Operators"
#:doc '(lib "plisqin-doc/scribblings/plisqin.scrbl")]