Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Mar 2023 12:37:49 GMT
From:      Guido Falsi <madpilot@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: b27d920aecff - main - deskutils/calibre: Fix at runtime after commit 47912ce2e613 (sqlite3)
Message-ID:  <202303011237.321CbnBr007935@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by madpilot:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b27d920aecff0eccd07de8feab1f5ee7d2c12621

commit b27d920aecff0eccd07de8feab1f5ee7d2c12621
Author:     Guido Falsi <madpilot@FreeBSD.org>
AuthorDate: 2023-03-01 12:33:37 +0000
Commit:     Guido Falsi <madpilot@FreeBSD.org>
CommitDate: 2023-03-01 12:33:37 +0000

    deskutils/calibre: Fix at runtime after commit 47912ce2e613 (sqlite3)
    
    In commit 47912ce2e613 to sqlite3 the default has been changed for the DQS option.
    
    Thius causes calibre to fail to open its database, reporting it as corrupted:
    
    Traceback (most recent call last):
      File "/usr/local/lib/calibre/calibre/gui2/main.py", line 331, in initialize_db
        db = LibraryDatabase(self.library_path)
      File "/usr/local/lib/calibre/calibre/db/legacy.py", line 195, in __init__
        backend = self.backend = create_backend(library_path, default_prefs=default_prefs,
      File "/usr/local/lib/calibre/calibre/db/legacy.py", line 50, in create_backend
        return DB(library_path, default_prefs=default_prefs,
      File "/usr/local/lib/calibre/calibre/db/backend.py", line 501, in __init__
        self.initialize_custom_columns()
      File "/usr/local/lib/calibre/calibre/db/backend.py", line 698, in initialize_custom_columns
        custom_tables = self.custom_tables
      File "/usr/local/lib/calibre/calibre/db/backend.py", line 1387, in custom_tables
        return {x[0] for x in self.conn.get(
      File "/usr/local/lib/calibre/calibre/db/backend.py", line 370, in get
        ans = self.cursor().execute(*args)
      File "src/cursor.c", line 992, in APSWCursor_execute.sqlite3_prepare
    apsw.SQLError: SQLError: no such column: table
    
    This patch fixes the use of double quotes in the code accessing the library database at runtime.
    
    Submitted upstream:     https://github.com/kovidgoyal/calibre/pull/1830
---
 deskutils/calibre/Makefile                           |  1 +
 .../calibre/files/patch-src_calibre_db_backend.py    | 13 +++++++++++++
 .../files/patch-src_calibre_db_schema__upgrades.py   | 20 ++++++++++++++++++++
 3 files changed, 34 insertions(+)

diff --git a/deskutils/calibre/Makefile b/deskutils/calibre/Makefile
index f567078eb1e7..b9372d066444 100644
--- a/deskutils/calibre/Makefile
+++ b/deskutils/calibre/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	calibre
 PORTVERSION=	6.13.0
+PORTREVISION=	1
 CATEGORIES=	deskutils python
 MASTER_SITES=	http://download.calibre-ebook.com/${PORTVERSION}/ \
 		https://curl.haxx.se/ca/:cacert
diff --git a/deskutils/calibre/files/patch-src_calibre_db_backend.py b/deskutils/calibre/files/patch-src_calibre_db_backend.py
new file mode 100644
index 000000000000..28408c27cef0
--- /dev/null
+++ b/deskutils/calibre/files/patch-src_calibre_db_backend.py
@@ -0,0 +1,13 @@
+--- src/calibre/db/backend.py.orig	2023-02-17 02:32:09 UTC
++++ src/calibre/db/backend.py
+@@ -1385,8 +1385,8 @@ class DB:
+     @property
+     def custom_tables(self):
+         return {x[0] for x in self.conn.get(
+-            'SELECT name FROM sqlite_master WHERE type="table" AND '
+-            '(name GLOB "custom_column_*" OR name GLOB "books_custom_column_*")')}
++            'SELECT name FROM sqlite_master WHERE type=\'table\' AND '
++            '(name GLOB \'custom_column_*\' OR name GLOB \'books_custom_column_*\')')}
+ 
+     @classmethod
+     def exists_at(cls, path):
diff --git a/deskutils/calibre/files/patch-src_calibre_db_schema__upgrades.py b/deskutils/calibre/files/patch-src_calibre_db_schema__upgrades.py
new file mode 100644
index 000000000000..12bf4aa855b4
--- /dev/null
+++ b/deskutils/calibre/files/patch-src_calibre_db_schema__upgrades.py
@@ -0,0 +1,20 @@
+--- src/calibre/db/schema_upgrades.py.orig	2023-02-17 02:32:09 UTC
++++ src/calibre/db/schema_upgrades.py
+@@ -300,7 +300,7 @@ class SchemaUpgrade:
+         for field in itervalues(self.field_metadata):
+             if field['is_category'] and not field['is_custom'] and 'link_column' in field:
+                 table = self.db.get(
+-                    'SELECT name FROM sqlite_master WHERE type="table" AND name=?',
++                    'SELECT name FROM sqlite_master WHERE type=\'table\' AND name=?',
+                     ('books_%s_link'%field['table'],), all=False)
+                 if table is not None:
+                     create_tag_browser_view(field['table'], field['link_column'], field['column'])
+@@ -376,7 +376,7 @@ class SchemaUpgrade:
+         for field in itervalues(self.field_metadata):
+             if field['is_category'] and not field['is_custom'] and 'link_column' in field:
+                 table = self.db.get(
+-                    'SELECT name FROM sqlite_master WHERE type="table" AND name=?',
++                    'SELECT name FROM sqlite_master WHERE type=\'table\' AND name=?',
+                     ('books_%s_link'%field['table'],), all=False)
+                 if table is not None:
+                     create_std_tag_browser_view(field['table'], field['link_column'],



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202303011237.321CbnBr007935>