The sxql-composer Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The sxql-composer Reference Manual

This is the sxql-composer Reference Manual, version 0.1, generated automatically by Declt version 3.0 "Montgomery Scott" on Fri Jun 26 12:20:05 2020 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

SXQL-COMPOSER

Quicklisp MIT License

Build and compose SXQL queries dynamically.

Motivation

It is not possible to dynamically build and compose SXQL queries because it uses macros for query building. For example, something like:

(defun build-query (fields &key order-by)
    (select fields
      (where (:= 'user.id 1))
      (when order-by
        (order-by order-by))))

is not possible.

SXQL-COMPOSER implements an equivalent set of functions in order to be able to either build new queries dynamically, or modify and composer already existent queries.

With SXQL-COMPOSER:

(defun build-query (fields &key order-by)
   (let ((q (select fields
               (where (:= 'user.id 1)))))
      (when order-by (order-by= q order-by))
      q))

Also, it is not possible to modify already existent queries. That is useful for filtering:

(defun all-users ()
   (select :* (from :users)))

(defun married-users ()
   (and-where (all-users)
       '(:= status "married")))

CL-ARROWS library is potentially useful for building the queries:

(defun married-users ()
   (-> (all-users)
      (and-where '(:= status "married"))))

Functions

and-where

(statement expression)

Add an AND clause to the WHERE clause of SQL STATEMENT

fields+

(statement &rest fields)

Add FIELDS to the SELECT SQL STATEMENT

fields=

(statement fields)

Set the FIELDS of the SELECT SQL STATEMENT

from+

(statement &rest tables)

Add TABLES to the FROM clause of the SQL STATEMENT

from=

(statement &rest tables)

Set the FROM clause of the SQL STATEMENT

group-by+

(statement &rest expressions)

Add expressions to the GROUP BY clause of the SQL STATEMENT

group-by=

(statement &rest expressions)

Set the GROUP BY clause of the SQL statement

limit=

(statement count1 &optional count2)

Set the LIMIT clause of the SQL STATEMENT

offset=

(statement offset)

Set the OFFSET clause of the SQL STATEMENT

or-where

(statement expression)

Add an OR clause to the WHERE clause of SQL STATEMENT

order-by+

(statement &rest expressions)

Add EXPRESSIONS ot the ORDER BY clause of the SQL STATEMENT

order-by=

(statement &rest expressions)

Set the ORDER BY clause of the SQL STATEMENT

returning=

(statement expression)

Set the RETURNING clause of SQL STATEMENT

where=

(statement expression)

Set SQL WHERE clause of the SQL STATEMENT


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 sxql-composer

Author

Mariano Montone <marianomontone@gmail.com>

License

MIT

Description

Build and compose SXQL queries dynamically

Version

0.1

Dependency

sxql

Source

sxql-composer.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 sxql-composer.asd

Location

sxql-composer.asd

Systems

sxql-composer (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 sxql-composer/package.lisp

Parent

sxql-composer (system)

Location

package.lisp

Packages

sxql-composer


Previous: , Up: Lisp files   [Contents][Index]

3.1.3 sxql-composer/sxql-composer.lisp

Dependency

package.lisp (file)

Parent

sxql-composer (system)

Location

sxql-composer.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 sxql-composer

Dynamic SXQL query composition

Source

package.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Functions

Function: and-where STATEMENT EXPRESSION

Add an AND clause to the WHERE clause of SQL STATEMENT

Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: fields+ STATEMENT &rest FIELDS

Add FIELDS to the SELECT SQL STATEMENT

Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: fields= STATEMENT FIELDS

Set the FIELDS of the SELECT SQL STATEMENT

Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: from+ STATEMENT &rest TABLES

Add TABLES to the FROM clause of the SQL STATEMENT

Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: from= STATEMENT &rest TABLES

Set the FROM clause of the SQL STATEMENT

Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: group-by+ STATEMENT &rest EXPRESSIONS

Add expressions to the GROUP BY clause of the SQL STATEMENT

Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: group-by= STATEMENT &rest EXPRESSIONS

Set the GROUP BY clause of the SQL statement

Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: limit= STATEMENT COUNT1 &optional COUNT2

Set the LIMIT clause of the SQL STATEMENT

Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: offset= STATEMENT OFFSET

Set the OFFSET clause of the SQL STATEMENT

Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: or-where STATEMENT EXPRESSION

Add an OR clause to the WHERE clause of SQL STATEMENT

Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: order-by+ STATEMENT &rest EXPRESSIONS

Add EXPRESSIONS ot the ORDER BY clause of the SQL STATEMENT

Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: order-by= STATEMENT &rest EXPRESSIONS

Set the ORDER BY clause of the SQL STATEMENT

Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: returning= STATEMENT EXPRESSION

Set the RETURNING clause of SQL STATEMENT

Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: where= STATEMENT EXPRESSION

Set SQL WHERE clause of the SQL STATEMENT

Package

sxql-composer

Source

sxql-composer.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Functions

Function: expand-expression EXPRESSIONS
Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: expand-op OBJECT
Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: fields STATEMENT FIELDS &optional ACTION
Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: from* STATEMENT TABLE-OR-TABLES &optional ACTION
Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: group-by* STATEMENT EXPRESSIONS &optional ACTION
Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: order-by* STATEMENT EXPRESSIONS &optional ACTION
Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: set-child STATEMENT CHILD
Package

sxql-composer

Source

sxql-composer.lisp (file)

Function: where* STATEMENT EXPRESSION &optional ACTION
Package

sxql-composer

Source

sxql-composer.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   S  
Index Entry  Section

F
File, Lisp, sxql-composer.asd: The sxql-composer․asd file
File, Lisp, sxql-composer/package.lisp: The sxql-composer/package․lisp file
File, Lisp, sxql-composer/sxql-composer.lisp: The sxql-composer/sxql-composer․lisp file

L
Lisp File, sxql-composer.asd: The sxql-composer․asd file
Lisp File, sxql-composer/package.lisp: The sxql-composer/package․lisp file
Lisp File, sxql-composer/sxql-composer.lisp: The sxql-composer/sxql-composer․lisp file

S
sxql-composer.asd: The sxql-composer․asd file
sxql-composer/package.lisp: The sxql-composer/package․lisp file
sxql-composer/sxql-composer.lisp: The sxql-composer/sxql-composer․lisp file

Jump to:   F   L   S  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   A   E   F   G   L   O   R   S   W  
Index Entry  Section

A
and-where: Exported functions

E
expand-expression: Internal functions
expand-op: Internal functions

F
fields: Internal functions
fields+: Exported functions
fields=: Exported functions
from*: Internal functions
from+: Exported functions
from=: Exported functions
Function, and-where: Exported functions
Function, expand-expression: Internal functions
Function, expand-op: Internal functions
Function, fields: Internal functions
Function, fields+: Exported functions
Function, fields=: Exported functions
Function, from*: Internal functions
Function, from+: Exported functions
Function, from=: Exported functions
Function, group-by*: Internal functions
Function, group-by+: Exported functions
Function, group-by=: Exported functions
Function, limit=: Exported functions
Function, offset=: Exported functions
Function, or-where: Exported functions
Function, order-by*: Internal functions
Function, order-by+: Exported functions
Function, order-by=: Exported functions
Function, returning=: Exported functions
Function, set-child: Internal functions
Function, where*: Internal functions
Function, where=: Exported functions

G
group-by*: Internal functions
group-by+: Exported functions
group-by=: Exported functions

L
limit=: Exported functions

O
offset=: Exported functions
or-where: Exported functions
order-by*: Internal functions
order-by+: Exported functions
order-by=: Exported functions

R
returning=: Exported functions

S
set-child: Internal functions

W
where*: Internal functions
where=: Exported functions

Jump to:   A   E   F   G   L   O   R   S   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables


Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   P   S  
Index Entry  Section

P
Package, sxql-composer: The sxql-composer package

S
sxql-composer: The sxql-composer system
sxql-composer: The sxql-composer package
System, sxql-composer: The sxql-composer system

Jump to:   P   S