From 448dcf32eddb695c9d2f06ca26f2755e8b185330 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Wed, 21 May 2025 14:03:27 +0200 Subject: [PATCH] update emacsql --- bba.org | 2 +- .../emacsql-sqlite-common.el | 22 ------ .../README.md | 18 ++--- .../emacsql-autoloads.el | 0 .../emacsql-compiler.el | 22 +++--- .../emacsql-mysql.el | 0 .../emacsql-pg.el | 0 .../emacsql-pkg.el | 6 +- .../emacsql-psql.el | 0 .../emacsql-sqlite-builtin.el | 10 ++- .../emacsql-sqlite-module.el | 2 +- .../emacsql-sqlite.el | 25 +++---- .../emacsql.el | 71 ++++++------------- 13 files changed, 67 insertions(+), 111 deletions(-) delete mode 100644 elpa/emacsql-20241201.1551/emacsql-sqlite-common.el rename elpa/{emacsql-20241201.1551 => emacsql-20250401.1500}/README.md (99%) rename elpa/{emacsql-20241201.1551 => emacsql-20250401.1500}/emacsql-autoloads.el (100%) rename elpa/{emacsql-20241201.1551 => emacsql-20250401.1500}/emacsql-compiler.el (97%) rename elpa/{emacsql-20241201.1551 => emacsql-20250401.1500}/emacsql-mysql.el (100%) rename elpa/{emacsql-20241201.1551 => emacsql-20250401.1500}/emacsql-pg.el (100%) rename elpa/{emacsql-20241201.1551 => emacsql-20250401.1500}/emacsql-pkg.el (70%) rename elpa/{emacsql-20241201.1551 => emacsql-20250401.1500}/emacsql-psql.el (100%) rename elpa/{emacsql-20241201.1551 => emacsql-20250401.1500}/emacsql-sqlite-builtin.el (93%) rename elpa/{emacsql-20241201.1551 => emacsql-20250401.1500}/emacsql-sqlite-module.el (98%) rename elpa/{emacsql-20241201.1551 => emacsql-20250401.1500}/emacsql-sqlite.el (94%) rename elpa/{emacsql-20241201.1551 => emacsql-20250401.1500}/emacsql.el (86%) diff --git a/bba.org b/bba.org index 8cce2bfc..0a4fce93 100644 --- a/bba.org +++ b/bba.org @@ -239,7 +239,7 @@ from bash. BUGBUG #+begin_src sql emacs-lisp :tangle no - (add-to-list 'load-path "~/.emacs.d/elpa/emacsql-20241201.1551") + (add-to-list 'load-path "~/.emacs.d/elpa/emacsql-20250401.1500") (require 'emacsql) (add-to-list 'load-path "~/.emacs.d/elpa/emacsql-sqlite-20230225.2205") diff --git a/elpa/emacsql-20241201.1551/emacsql-sqlite-common.el b/elpa/emacsql-20241201.1551/emacsql-sqlite-common.el deleted file mode 100644 index 129d1401..00000000 --- a/elpa/emacsql-20241201.1551/emacsql-sqlite-common.el +++ /dev/null @@ -1,22 +0,0 @@ -;;; emacsql-sqlite-common.el --- Transitional library that should not be loaded -*- lexical-binding:t -*- - -;; This is free and unencumbered software released into the public domain. - -;; Author: Jonas Bernoulli -;; Maintainer: Jonas Bernoulli - -;; SPDX-License-Identifier: Unlicense - -;;; Commentary: - -;; Transitional library that should not be loaded. If your package still -;; requires this library, change it to require `emacsql-sqlite' instead. - -;;; Code: - -(require 'emacsql-sqlite) - -(provide 'emacsql-sqlite-common) - -;;; emacsql-sqlite-common.el ends here - diff --git a/elpa/emacsql-20241201.1551/README.md b/elpa/emacsql-20250401.1500/README.md similarity index 99% rename from elpa/emacsql-20241201.1551/README.md rename to elpa/emacsql-20250401.1500/README.md index 7185c3cf..5a6e0041 100644 --- a/elpa/emacsql-20241201.1551/README.md +++ b/elpa/emacsql-20250401.1500/README.md @@ -146,6 +146,16 @@ For function-like "operators" like `count` and `max` use the `funcall` [:select (funcall max age) :from people] ``` +With `glob` and `like` SQL operators keep in mind that they're +matching the *printed* representations of these values, even if the +value is a string. + +The `||` concatenation operator is unsupported because concatenating +printed representations breaks an important constraint: all values must +remain readable within SQLite. + +## Quoting + Inside expressions, EmacSQL cannot tell the difference between symbol literals and column references. If you're talking about the symbol itself, just quote it as you would in normal Elisp. Note that this @@ -169,14 +179,6 @@ returned as results. Since template parameters include their type they never need to be quoted. -With `glob` and `like` SQL operators keep in mind that they're -matching the *printed* representations of these values, even if the -value is a string. - -The `||` concatenation operator is unsupported because concatenating -printed representations breaks an important constraint: all values must -remain readable within SQLite. - ## Prepared Statements The database is interacted with via prepared SQL s-expression diff --git a/elpa/emacsql-20241201.1551/emacsql-autoloads.el b/elpa/emacsql-20250401.1500/emacsql-autoloads.el similarity index 100% rename from elpa/emacsql-20241201.1551/emacsql-autoloads.el rename to elpa/emacsql-20250401.1500/emacsql-autoloads.el diff --git a/elpa/emacsql-20241201.1551/emacsql-compiler.el b/elpa/emacsql-20250401.1500/emacsql-compiler.el similarity index 97% rename from elpa/emacsql-20241201.1551/emacsql-compiler.el rename to elpa/emacsql-20250401.1500/emacsql-compiler.el index 12a70823..575af47c 100644 --- a/elpa/emacsql-20241201.1551/emacsql-compiler.el +++ b/elpa/emacsql-20250401.1500/emacsql-compiler.el @@ -1,4 +1,4 @@ -;;; emacsql-compile.el --- S-expression SQL compiler -*- lexical-binding:t -*- +;;; emacsql-compiler.el --- S-expression SQL compiler -*- lexical-binding:t -*- ;; This is free and unencumbered software released into the public domain. @@ -7,6 +7,10 @@ ;; SPDX-License-Identifier: Unlicense +;;; Commentary: + +;; This library provides support for compiling S-expressions to SQL. + ;;; Code: (require 'cl-lib) @@ -122,7 +126,7 @@ (defun emacsql-escape-vector (vector) "Encode VECTOR into a SQL vector scalar." (cl-typecase vector - (null (emacsql-error "Empty SQL vector expression.")) + (null (emacsql-error "Empty SQL vector expression")) (list (mapconcat #'emacsql-escape-vector vector ", ")) (vector (concat "(" (mapconcat #'emacsql-escape-scalar vector ", ") ")")) (otherwise (emacsql-error "Invalid vector %S" vector)))) @@ -146,7 +150,7 @@ (upcase (replace-regexp-in-string "-" " " name)))) (defun emacsql--prepare-constraints (constraints) - "Compile CONSTRAINTS into a partial SQL expresson." + "Compile CONSTRAINTS into a partial SQL expression." (mapconcat #'identity (cl-loop for constraint in constraints collect @@ -225,7 +229,7 @@ vector (v), raw string (r), schema (S)." (defmacro emacsql-with-params (prefix &rest body) "Evaluate BODY, collecting parameters. Provided local functions: `param', `identifier', `scalar', `raw', -`svector', `expr', `subsql', and `combine'. BODY should return a +`svector', `expr', `subsql', and `combine'. BODY should return a string, which will be combined with variable definitions." (declare (indent 1)) `(let ((emacsql--vars ())) @@ -283,15 +287,15 @@ The generated function is bound to NAME and accepts two arguments, OPERATOR-NAME and OPERATOR-ARGUMENT-COUNT. OPERATOR-PRECEDENCE-GROUPS should be a number of lists containing operators grouped by operator precedence (in order of precedence -from highest to lowest). A single operator is represented by a +from highest to lowest). A single operator is represented by a list of at least two elements: operator name (symbol) and -operator arity (:unary or :binary). Optionally a custom +operator arity (:unary or :binary). Optionally a custom expression can be included, which defines how the operator is expanded into an SQL expression (there are two defaults, one for :unary and one for :binary operators). An example for OPERATOR-PRECEDENCE-GROUPS: -(((+ :unary (\"+\" :operand)) (- :unary (\"-\" :operand))) +\(((+ :unary (\"+\" :operand)) (- :unary (\"-\" :operand))) ((+ :binary) (- :binary)))" `(defun ,name (operator-name operator-argument-count) "Look up predefined SQL operator metadata. @@ -366,7 +370,7 @@ to create an SQL expression." "Lookup SQL operator information for generating an SQL expression. Returns the following multiple values when an operator can be identified: a format string (see `emacsql--expand-format-string') -and a precedence value. If PARENT-PRECEDENCE-VALUE is greater or +and a precedence value. If PARENT-PRECEDENCE-VALUE is greater or equal to the identified operator's precedence, then the format string returned is wrapped with parentheses." (cl-destructuring-bind (format-string arity precedence-value) @@ -539,4 +543,4 @@ Only use within `emacsql-with-params'!" (provide 'emacsql-compiler) -;;; emacsql-compile.el ends here +;;; emacsql-compiler.el ends here diff --git a/elpa/emacsql-20241201.1551/emacsql-mysql.el b/elpa/emacsql-20250401.1500/emacsql-mysql.el similarity index 100% rename from elpa/emacsql-20241201.1551/emacsql-mysql.el rename to elpa/emacsql-20250401.1500/emacsql-mysql.el diff --git a/elpa/emacsql-20241201.1551/emacsql-pg.el b/elpa/emacsql-20250401.1500/emacsql-pg.el similarity index 100% rename from elpa/emacsql-20241201.1551/emacsql-pg.el rename to elpa/emacsql-20250401.1500/emacsql-pg.el diff --git a/elpa/emacsql-20241201.1551/emacsql-pkg.el b/elpa/emacsql-20250401.1500/emacsql-pkg.el similarity index 70% rename from elpa/emacsql-20241201.1551/emacsql-pkg.el rename to elpa/emacsql-20250401.1500/emacsql-pkg.el index da87bbf0..e5a99bfe 100644 --- a/elpa/emacsql-20241201.1551/emacsql-pkg.el +++ b/elpa/emacsql-20250401.1500/emacsql-pkg.el @@ -1,9 +1,9 @@ ;; -*- no-byte-compile: t; lexical-binding: nil -*- -(define-package "emacsql" "20241201.1551" +(define-package "emacsql" "20250401.1500" "High-level SQL database front-end." '((emacs "26.1")) :url "https://github.com/magit/emacsql" - :commit "d6529f010a0573630122b826230e72157ab8fa88" - :revdesc "d6529f010a05" + :commit "5470adaf5dcabebc80c913ac831258fd47a87cbe" + :revdesc "5470adaf5dca" :authors '(("Christopher Wellons" . "wellons@nullprogram.com")) :maintainers '(("Jonas Bernoulli" . "emacs.emacsql@jonas.bernoulli.dev"))) diff --git a/elpa/emacsql-20241201.1551/emacsql-psql.el b/elpa/emacsql-20250401.1500/emacsql-psql.el similarity index 100% rename from elpa/emacsql-20241201.1551/emacsql-psql.el rename to elpa/emacsql-20250401.1500/emacsql-psql.el diff --git a/elpa/emacsql-20241201.1551/emacsql-sqlite-builtin.el b/elpa/emacsql-20250401.1500/emacsql-sqlite-builtin.el similarity index 93% rename from elpa/emacsql-20241201.1551/emacsql-sqlite-builtin.el rename to elpa/emacsql-20250401.1500/emacsql-sqlite-builtin.el index b98e6967..94edd26c 100644 --- a/elpa/emacsql-20241201.1551/emacsql-sqlite-builtin.el +++ b/elpa/emacsql-20250401.1500/emacsql-sqlite-builtin.el @@ -16,10 +16,9 @@ (require 'emacsql-sqlite) -(require 'sqlite nil t) -(declare-function sqlite-open "sqlite") -(declare-function sqlite-select "sqlite") -(declare-function sqlite-close "sqlite") +(declare-function sqlite-open "sqlite.c") +(declare-function sqlite-select "sqlite.c") +(declare-function sqlite-close "sqlite.c") (emacsql-register-reserved emacsql-sqlite-reserved) @@ -28,7 +27,6 @@ (cl-defmethod initialize-instance :after ((connection emacsql-sqlite-builtin-connection) &rest _) - (require (quote sqlite)) (oset connection handle (sqlite-open (oref connection file))) (emacsql-sqlite-set-busy-timeout connection) @@ -40,7 +38,7 @@ If FILE is nil use an in-memory database. :debug LOG -- When non-nil, log all SQLite commands to a log -buffer. This is for debugging purposes." +buffer. This is for debugging purposes." (let ((connection (make-instance #'emacsql-sqlite-builtin-connection :file file))) (when debug diff --git a/elpa/emacsql-20241201.1551/emacsql-sqlite-module.el b/elpa/emacsql-20250401.1500/emacsql-sqlite-module.el similarity index 98% rename from elpa/emacsql-20241201.1551/emacsql-sqlite-module.el rename to elpa/emacsql-20250401.1500/emacsql-sqlite-module.el index c3cf29ca..8dd1986e 100644 --- a/elpa/emacsql-20241201.1551/emacsql-sqlite-module.el +++ b/elpa/emacsql-20250401.1500/emacsql-sqlite-module.el @@ -44,7 +44,7 @@ If FILE is nil use an in-memory database. :debug LOG -- When non-nil, log all SQLite commands to a log -buffer. This is for debugging purposes." +buffer. This is for debugging purposes." (let ((connection (make-instance #'emacsql-sqlite-module-connection :file file))) (when debug diff --git a/elpa/emacsql-20241201.1551/emacsql-sqlite.el b/elpa/emacsql-20250401.1500/emacsql-sqlite.el similarity index 94% rename from elpa/emacsql-20241201.1551/emacsql-sqlite.el rename to elpa/emacsql-20250401.1500/emacsql-sqlite.el index 753ee80b..3add7aeb 100644 --- a/elpa/emacsql-20241201.1551/emacsql-sqlite.el +++ b/elpa/emacsql-20250401.1500/emacsql-sqlite.el @@ -1,4 +1,4 @@ -;;; emacsql-sqlite.el --- Code used by multiple SQLite back-ends -*- lexical-binding:t -*- +;;; emacsql-sqlite.el --- Code used by both SQLite back-ends -*- lexical-binding:t -*- ;; This is free and unencumbered software released into the public domain. @@ -9,7 +9,7 @@ ;;; Commentary: -;; This library contains code that is used by multiple SQLite back-ends. +;; This library contains code that is used by both SQLite back-ends. ;;; Code: @@ -213,18 +213,19 @@ been remove, so we can no longer fall back to that. (nreverse value))) (defun emacsql-sqlite-list-tables (connection) - "Return a list of the names of all tables in CONNECTION. + "Return a list of symbols identifying tables in CONNECTION. Tables whose names begin with \"sqlite_\", are not included in the returned value." - (emacsql connection - [:select name - ;; The new name is `sqlite-schema', but this name - ;; is supported by old and new SQLite versions. - ;; See https://www.sqlite.org/schematab.html. - :from sqlite-master - :where (and (= type 'table) - (not-like name "sqlite_%")) - :order-by [(asc name)]])) + (mapcar #'car + (emacsql connection + [:select name + ;; The new name is `sqlite-schema', but this name + ;; is supported by old and new SQLite versions. + ;; See https://www.sqlite.org/schematab.html. + :from sqlite-master + :where (and (= type 'table) + (not-like name "sqlite_%")) + :order-by [(asc name)]]))) (defun emacsql-sqlite-dump-database (connection &optional versionp) "Dump the database specified by CONNECTION to a file. diff --git a/elpa/emacsql-20241201.1551/emacsql.el b/elpa/emacsql-20250401.1500/emacsql.el similarity index 86% rename from elpa/emacsql-20241201.1551/emacsql.el rename to elpa/emacsql-20250401.1500/emacsql.el index 0c0f00a3..baea0210 100644 --- a/elpa/emacsql-20241201.1551/emacsql.el +++ b/elpa/emacsql-20250401.1500/emacsql.el @@ -6,8 +6,8 @@ ;; Maintainer: Jonas Bernoulli ;; Homepage: https://github.com/magit/emacsql -;; Package-Version: 20241201.1551 -;; Package-Revision: d6529f010a05 +;; Package-Version: 20250401.1500 +;; Package-Revision: 5470adaf5dca ;; Package-Requires: ((emacs "26.1")) ;; SPDX-License-Identifier: Unlicense @@ -33,17 +33,13 @@ "The EmacSQL SQL database front-end." :group 'comm) -(defconst emacsql-version "4.1.0") +(defconst emacsql-version "4.3.0") (defvar emacsql-global-timeout 30 "Maximum number of seconds to wait before bailing out on a SQL command. -If nil, wait forever. This is used by the `mysql', `pg', `psql' and -`sqlite' back-ends. It is not being used by the `sqlite-builtin' and -`sqlite-module' back-ends, which only use `emacsql-sqlite-busy-timeout'.") - -(defvar emacsql-data-root - (file-name-directory (or load-file-name buffer-file-name)) - "Directory where EmacSQL is installed.") +If nil, wait forever. This is used by the `mysql', `pg' and `psql'. It +is not being used by the `sqlite-builtin' and `sqlite-module' back-ends, +which respect `emacsql-sqlite-busy-timeout' instead.") ;;; Database connection @@ -79,8 +75,8 @@ may return `process', `user-ptr' or `sqlite' for this value.") "Return an alist mapping EmacSQL types to database types. This will mask `emacsql-type-map' during expression compilation. This alist should have four key symbols: integer, float, object, -nil (default type). The values are strings to be inserted into a -SQL expression.") +nil (default type). The values are strings to be inserted into +a SQL expression.") (cl-defmethod emacsql-buffer ((connection emacsql-connection)) "Get process buffer for CONNECTION." @@ -102,29 +98,6 @@ MESSAGE should not have a newline on the end." (goto-char (point-max)) (princ (concat message "\n") buffer))))) -(cl-defgeneric emacsql-process (this) - "Access internal `handle' slot directly, which you shouldn't do. -Using this function to do it anyway, means additionally using a -misnamed and obsolete accessor function." - (and (slot-boundp this 'handle) - (oref this handle))) -(cl-defmethod (setf emacsql-process) (value (this emacsql-connection)) - (oset this handle value)) -(make-obsolete 'emacsql-process "underlying slot is for internal use only." - "EmacSQL 4.0.0") - -(cl-defmethod slot-missing ((connection emacsql-connection) - slot-name operation &optional new-value) - "Treat removed `process' slot-name as an alias for internal `handle' slot." - (pcase (list operation slot-name) - ('(oref process) - (message "EmacSQL: Slot `process' is obsolete") - (oref connection handle)) - ('(oset process) - (message "EmacSQL: Slot `process' is obsolete") - (oset connection handle new-value)) - (_ (cl-call-next-method)))) - ;;; Sending and receiving (cl-defgeneric emacsql-send-message (connection message) @@ -160,8 +133,8 @@ misnamed and obsolete accessor function." (defun emacsql-compile (connection sql &rest args) "Compile s-expression SQL for CONNECTION into a string." - (let* ((mask (and connection (emacsql-types connection))) - (emacsql-type-map (or mask emacsql-type-map))) + (let ((emacsql-type-map (or (and connection (emacsql-types connection)) + emacsql-type-map))) (concat (apply #'emacsql-format (emacsql-prepare sql) args) ";"))) (cl-defgeneric emacsql (connection sql &rest args) @@ -178,9 +151,9 @@ misnamed and obsolete accessor function." (defclass emacsql-protocol-mixin () () "A mixin for back-ends following the EmacSQL protocol. -The back-end prompt must be a single \"]\" character. This prompt -value was chosen because it is unreadable. Output must have -exactly one row per line, fields separated by whitespace. NULL +The back-end prompt must be a single \"]\" character. This prompt +value was chosen because it is unreadable. Output must have +exactly one row per line, fields separated by whitespace. NULL must display as \"nil\"." :abstract t) @@ -206,14 +179,12 @@ specific error conditions." (goto-char (point-min)) (let* ((standard-input (current-buffer)) (value (read))) - (if (eql value 'error) + (if (eq value 'error) (emacsql-handle connection (read) (read)) (prog1 value - (unless (eq 'success (read)) + (unless (eq (read) 'success) (emacsql-handle connection (read) (read)))))))) -(provide 'emacsql) ; end of generic function declarations - ;;; Automatic connection cleanup (defun emacsql-register (connection) @@ -247,7 +218,7 @@ This macro can be nested indefinitely, wrapping everything in a single transaction at the lowest level. Warning: BODY should *not* have any side effects besides making -changes to the database behind CONNECTION. Body may be evaluated +changes to the database behind CONNECTION. Body may be evaluated multiple times before the changes are committed." (declare (indent 1)) `(let ((emacsql--connection ,connection) @@ -289,8 +260,8 @@ A statement can be a list, containing a statement with its arguments." Returns the result of the last evaluated BODY. All column names must be provided in the query ($ and * are not -allowed). Hint: all of the bound identifiers must be known at -compile time. For example, in the expression below the variables +allowed). Hint: all of the bound identifiers must be known at +compile time. For example, in the expression below the variables `name' and `phone' will be bound for the body. (emacsql-with-bind db [:select [name phone] :from people] @@ -307,8 +278,8 @@ Each column must be a plain symbol, no expressions allowed here." (args (and (not (vectorp sql-and-args)) (cdr sql-and-args)))) (cl-assert (eq :select (elt sql 0))) (let ((vars (elt sql 1))) - (when (eq '* vars) - (error "Must explicitly list columns in `emacsql-with-bind'.")) + (when (eq vars '*) + (error "Must explicitly list columns in `emacsql-with-bind'")) (cl-assert (cl-every #'symbolp vars)) `(let ((emacsql--results (emacsql ,connection ,sql ,@args)) (emacsql--final nil)) @@ -403,4 +374,6 @@ Once activated, vector contents no longer indent like lists." (advice-add 'calculate-lisp-indent :around #'emacsql--calculate-vector-indent)) +(provide 'emacsql) + ;;; emacsql.el ends here -- 2.47.3