[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql f030b9952d 224/427: Fix up psql-connection.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql f030b9952d 224/427: Fix up psql-connection. |
Date: |
Tue, 13 Dec 2022 02:59:46 -0500 (EST) |
branch: elpa/emacsql
commit f030b9952db9236585232685ef57919bd70a7a9d
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Fix up psql-connection.
---
emacsql-psql.el | 33 +++++++++++++++++++++++++++++++++
emacsql.el | 2 +-
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/emacsql-psql.el b/emacsql-psql.el
index aefaa98f3b..d873ff128b 100644
--- a/emacsql-psql.el
+++ b/emacsql-psql.el
@@ -78,6 +78,39 @@
(when (process-live-p process)
(process-send-string process "\\q\n"))))
+(defmethod emacsql-send-message ((connection emacsql-psql-connection) message)
+ (let ((process (emacsql-process connection)))
+ (process-send-string process message)
+ (process-send-string process "\n")))
+
+(defmethod emacsql-waiting-p ((connection emacsql-psql-connection))
+ (with-current-buffer (emacsql-buffer connection)
+ (cond ((= (buffer-size) 1) (string= "]" (buffer-string)))
+ ((> (buffer-size) 1) (string= "\n]"
+ (buffer-substring
+ (- (point-max) 2) (point-max)))))))
+
+(defmethod emacsql-check-error ((connection emacsql-psql-connection))
+ (with-current-buffer (emacsql-buffer connection)
+ (let ((case-fold-search t))
+ (setf (point) (point-min))
+ (when (looking-at "error:")
+ (let* ((beg (line-beginning-position))
+ (end (line-end-position)))
+ (signal 'emacsql-error (list (buffer-substring beg end))))))))
+
+(defmethod emacsql-parse ((connection emacsql-psql-connection))
+ (emacsql-check-error connection)
+ (with-current-buffer (emacsql-buffer connection)
+ (let ((standard-input (current-buffer)))
+ (setf (point) (point-min))
+ (cl-loop until (looking-at "]")
+ collect (read) into row
+ when (looking-at "\n")
+ collect row into rows
+ and do (progn (forward-char 1) (setf row ()))
+ finally (cl-return rows)))))
+
(provide 'emacsql-psql)
;;; emacsql-psql.el ends here
diff --git a/emacsql.el b/emacsql.el
index c1148e5d6a..39212614ff 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -171,7 +171,7 @@ must display as \"nil\".")
"Signal a specific condition for CODE from CONNECTION.
Subclasses should override this method in order to provide more
specific error conditions."
- (signal 'emacsql-syntax (list code message)))
+ (signal 'emacsql-error (list code message)))
(defmethod emacsql-parse ((connection emacsql-protocol-mixin))
"Parse well-formed output into an s-expression."
- [nongnu] elpa/emacsql 1db49d7f4c 090/427: Add Windows notice again., (continued)
- [nongnu] elpa/emacsql 1db49d7f4c 090/427: Add Windows notice again., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1ad58cd68d 108/427: Allow substatement in IN operator., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8fa7c00978 170/427: Add sentinel cleanup to psql., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6d17256e1b 171/427: Add a mix-in class to reduce code duplication., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 749becb017 181/427: Disable notices and warnings in psql., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e42d939235 187/427: In SQLite, block for up to 30 seconds on db lock., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3ba9109d45 198/427: Start using real version numbers., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql de0bde9a02 207/427: Use Cask package-file directive instead., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql bb3dbfc891 213/427: Set a global query timeout., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 394bb062aa 219/427: Add a small library for determining binary to use., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f030b9952d 224/427: Fix up psql-connection.,
ELPA Syncer <=
- [nongnu] elpa/emacsql dc2afbbc1f 221/427: Adjust the Emacsql wire protocol., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6318472b20 223/427: Link the Makefiles together., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a7728339ba 216/427: Switch to custom middleware., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ab53199d07 232/427: Fix escaping issue in middleware., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6ad267f93b 229/427: Change :value to :scalar., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1146f2e26a 233/427: Flesh out the changes in the README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ed77eac846 237/427: Add string prepared statements., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 847196cafa 226/427: Set tty to raw in psql., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3e5ce21b0d 242/427: Tweak the new implementation notes., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a459708684 244/427: Move tests into their own directory., ELPA Syncer, 2022/12/13