GNU bug report logs -
#70145
[PATCH] Add sqlite-execute-batch command
Previous Next
Reported by: Javier Olaechea <pirata <at> gmail.com>
Date: Tue, 2 Apr 2024 15:05:01 UTC
Severity: normal
Tags: patch
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 70145 <at> debbugs.gnu.org (full text, mbox):
> From: Javier Olaechea <pirata <at> gmail.com>
> Date: Tue, 2 Apr 2024 10:03:30 -0500
>
> Hi, while writing tests for an Emacs package I found myself needing to
> execute multiple statements against an in-memory database, to initialize
> the schema. Currently there is no easy way to do so as sqlite-execute
> only executes the first command and ignores the rest. The reason most
> likely being that accepting arguments for multiple statements and
> properly preparing would be a tricky task. So instead I'm adding the
> functionality as a new function that takes no arguments.
Thanks.
> +DEFUN ("sqlite-execute-batch", Fsqlite_execute_batch, Ssqlite_execute_batch, 2, 2, 0,
> + doc: /* Execute multiple SQL statements. */)
> + (Lisp_Object db, Lisp_Object query)
> +{
> + check_sqlite (db, false);
> + CHECK_STRING (query);
> + return sqlite_exec (XSQLITE (db)->db, SSDATA (query));
> +}
> +
This has a subtle bug: it will only work correctly for plain-ASCII
string in QUERY. If QUERY is allowed to included non-ASCII
characters, you need to encode it using encode_string.
Also, the doc string should mention the function's arguments, and it
should say what kind of Lisp object is QUERY.
> +@defun sqlite-execute-batch db statements
> +Execute the @acronym{SQL} @var{statements}. This might be useful when we
> +want to execute multiple @acronym{DDL} statements.
Same here, and in addition please leave two spaces between sentences,
per our conventions (in the commit log message as well).
This bug report was last modified 350 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.