cl-2sql

Lisp to SQL compiler for Common Lisp
git clone https://logand.com/git/cl-2sql.git/
Log | Files | Refs | README | LICENSE

README (5730B)


      1 -*- org -*-
      2 
      3 http://ondoc.logand.com/d/900/5/
      4 http://users.encs.concordia.ca/~haarslev/publications/jvlc92/node6.html
      5 http://www.cliki.net/MOP%20design%20patterns
      6 http://www.alu.org/mop/concepts.html
      7 http://www.alu.org/mop/dictionary.html
      8 http://www.lispworks.com/documentation/lw60/LW/html/lw-227.htm
      9 
     10 
     11 
     12 - meta-syntax with keywords (small, fast, not extensible)
     13 - syntax with macros (M-. etc)
     14 
     15 - programmable and evolvable sql syntax
     16 - embracing many sql dialects
     17 
     18 - no custom reader
     19   - http://clsql.b9.com/manual/csql-find.html
     20   - hu.dwim.rdbms
     21 - not keyword based
     22   - http://marijnhaverbeke.nl/postmodern/s-sql.html
     23   - completion, M-.
     24 - not class based
     25   - classes are for state, not syntax
     26   - bloat (rdbms)
     27     - sins: oo for syntax, format, custom readers
     28 - the above => arbitrary magic
     29   - we are defining syntax, right?
     30   - make use of lisp then (macros)
     31 
     32 - join proper prefix (tree of tables/selects)
     33 
     34 - minimal core meta-syntax and user macro layer
     35 
     36 - write obscure sql rules once in one place (macro)
     37 - ease sql portability
     38 
     39 
     40 
     41 
     42 - qvar: query parameter
     43 
     44 - qchunk: code evaluated when the query is executed, pasted into the
     45   query string directly
     46 
     47   - to suppress-qvar, e.g. when qvar cant be used as a sql function
     48     parameter
     49 
     50   - for "unanticipated" delayed calculations, like portable full text
     51     search
     52 
     53 http://www.bricklin.com/firstspreadsheetquestion.htm
     54 
     55 > But VisiCalc was not an accounting program at all, it just made it
     56 > possible for people to do accounting. Programs that were overly
     57 > tuned for such function (Javelin, Lotus Improv, etc.) completely
     58 > failed...What made VisiCalc novel was the ability to not only
     59 > interact but have it learn by example. Again, VisiCalc doesn't
     60 > summarize or do anything, it is just a tool to allow others to work
     61 > out their ideas and reduce the tedium of repeating the same
     62 > calculations.
     63 
     64 
     65 
     66 
     67 
     68 
     69 
     70                                  2sql
     71 
     72                             Tomas Hlavaty
     73                    <http://logand.com/contact.html>
     74 
     75                               2011-09-06
     76 
     77                          Updated: 2011-09-07
     78 
     79 2sql is an extensible Lisp to SQL compiler and runtime with ORM layer
     80 built on top of it.
     81 
     82                           Table of Contents
     83                           =================
     84 
     85   - Motivation and comparison with other projects
     86   - Dependencies
     87   - 2sql compiler
     88     - Printer
     89     - Compiler
     90     - Macros
     91     - Backends
     92     - Full text search
     93     - Portability
     94   - Object Relational Mapping
     95     - Custom persistent slot types
     96     - Inheritance
     97     - Schema evolution
     98     - Portability
     99 
    100             Motivation and comparison with other projects
    101             =============================================
    102 
    103                              Dependencies
    104                              ============
    105 
    106   - split-sequence
    107   - ironclad
    108   - babel
    109   - cl-postgres
    110   - sqlite
    111   - closer-mop
    112 
    113                             2sql compiler
    114                             =============
    115 
    116                                Printer
    117                                -------
    118 
    119                                Compiler
    120                                --------
    121 
    122                                 Macros
    123                                 ------
    124 
    125                                Backends
    126                                --------
    127 
    128                            Full text search
    129                            ----------------
    130 
    131                              Portability
    132                              -----------
    133 
    134                       Object Relational Mapping
    135                       =========================
    136 
    137 Use 2SQL-ORM:DEFPCLASS to define persistent classes or use DEFCLASS
    138 directly and inherit from 2SQL-ORM::PERSISTENT-OBJECT and specify
    139 :METACLASS 2SQL-ORM::PERSISTENT-CLASS.  If the persistent class
    140 inherits from mixins, those must have the persistent class metaclass
    141 too.
    142 
    143 To create a persistent instance, use MAKE-PINSTANCE.
    144 
    145 Instance cache must be manually cleared as necessary when using UPDATE
    146 or DELETE-FROM SQL commands except when:
    147 
    148   - SETF on a persistent slot is used;
    149   - DELETE-PINSTANCE is called.
    150 
    151                      Custom persistent slot types
    152                      ----------------------------
    153 
    154 Types must be specified for all persistent slots because the SQL types
    155 are derived from the Lisp types.  Use 2SQL-ORM:DEFPTYPE to define new
    156 Lisp type with SQL type mapping.  For example,
    157 
    158 CODE
    159   (2sql-orm:defptype username () '(2sql-orm:text 32 3))
    160 END
    161 
    162 defines a new type username where (< 3 (length a) 32).
    163 
    164                              Inheritance
    165                              -----------
    166 
    167 Persistent class inheritance is supported.  The concept lives only on
    168 the lisp side and does not map to table inheritance even if supported
    169 by the database backend.
    170 
    171                            Schema evolution
    172                            ----------------
    173 
    174 TODO Schema evolution not implemented yet
    175 
    176                              Portability
    177                              -----------
    178 
    179 2sql-orm is less portable then plain 2sql because of feature mismatch
    180 between database backends and varied MOP compatibility between
    181 different Lisps.
    182 
    183               |            | sbcl | ccl | clisp | ecl |
    184               |------------+------+-----+-------+-----|
    185               | postgresql | Y    |     |       |     |
    186               | sqlite     |      |     |       |     |
    187               | oracle     |      |     |       |     |
    188               | mysql      |      |     |       |     |
    189 
    190 Currently works on sbcl only.
    191 
    192   - TODO fix ccl issue with proxy: ccl is strict with types.  Slot
    193     type should probably be something like (or proxy user) or so.
    194 
    195   - TODO clisp crashes
    196 
    197   - TODO ecl has issues with deftype?
    198 
    199   - TODO sqlite doesn't have sequences, needed for oid (mysql have
    200     similar problem?)