diff options
Diffstat (limited to 'dlang/src/ocda/load_db.d')
| -rw-r--r-- | dlang/src/ocda/load_db.d | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/dlang/src/ocda/load_db.d b/dlang/src/ocda/load_db.d index dec0626..eb3d71b 100644 --- a/dlang/src/ocda/load_db.d +++ b/dlang/src/ocda/load_db.d @@ -132,6 +132,16 @@ OcdaDocument loadDbFile(string path, string lang = "", bool any_version = false) } } + /+ ↓ 2.1 added the container range as two columns. A 2.0 database has + neither, and reads as having no range, which is what 2.0 meant. +/ + bool has_range = false; + foreach (c; db.rows("PRAGMA table_info(objects)")) { + if (c[1] == "ocn_range_first") { has_range = true; } + } + string range_cols = has_range + ? "coalesce(ocn_range_first,0), coalesce(ocn_range_last,0)" + : "0, 0"; + /+ ↓ the objects, in document order within each section +/ foreach (r; db.rows( "SELECT section, seq, ocn, is_a, coalesce(is_of_part,''), @@ -152,7 +162,7 @@ OcdaDocument loadDbFile(string path, string lang = "", bool any_version = false) coalesce(code_linenumbers,0), coalesce(heading_ancestors_text,''), coalesce(sha256,''), coalesce(text,''), id, coalesce(heading_lev_anchor,''), - coalesce(segment_epub,''), coalesce(segment_epub_is,'') + coalesce(segment_epub,''), coalesce(segment_epub_is,''), " ~ range_cols ~ " FROM objects WHERE doc_id = " ~ chosen.doc_id.to!string ~ " ORDER BY CASE section WHEN 'head' THEN 1 WHEN 'toc' THEN 2 WHEN 'body' THEN 3 @@ -192,6 +202,8 @@ OcdaDocument loadDbFile(string path, string lang = "", bool any_version = false) obj.heading_lev_anchor = r[37]; obj.segment_epub = r[38]; obj.segment_epub_is = r[39]; + obj.ocn_range_first = r[40].to!int; + obj.ocn_range_last = r[41].to!int; obj.table_cols = r[28].to!int; obj.table_widths = jsonWords(r[29]); obj.table_aligns = jsonWords(r[30]); |
