Skip to content

Commit 8c78a66

Browse files
committed
fix(jdbc): add missing description for DriverPropertyInfo
Closes: #416
1 parent 22720f1 commit 8c78a66

File tree

2 files changed

+114
-52
lines changed

2 files changed

+114
-52
lines changed

src/main/java/org/sqlite/SQLiteConfig.java

Lines changed: 107 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ public void setExplicitReadOnly(boolean readOnly) {
373373
this.explicitReadOnly = readOnly;
374374
}
375375

376-
public static enum Pragma {
376+
public enum Pragma {
377377

378378
// Parameters requiring SQLite3 API invocation
379379
OPEN_MODE("open_mode", "Database open-mode flag", null),
@@ -384,34 +384,86 @@ public static enum Pragma {
384384
OnOff),
385385

386386
// Pragmas that can be set after opening the database
387-
CACHE_SIZE("cache_size"),
388-
MMAP_SIZE("mmap_size"),
389-
CASE_SENSITIVE_LIKE("case_sensitive_like", OnOff),
390-
COUNT_CHANGES("count_changes", OnOff),
391-
DEFAULT_CACHE_SIZE("default_cache_size"),
392-
DEFER_FOREIGN_KEYS("defer_foreign_keys", OnOff),
393-
EMPTY_RESULT_CALLBACKS("empty_result_callback", OnOff),
394-
ENCODING("encoding", toStringArray(Encoding.values())),
395-
FOREIGN_KEYS("foreign_keys", OnOff),
396-
FULL_COLUMN_NAMES("full_column_names", OnOff),
397-
FULL_SYNC("fullsync", OnOff),
398-
INCREMENTAL_VACUUM("incremental_vacuum"),
399-
JOURNAL_MODE("journal_mode", toStringArray(JournalMode.values())),
400-
JOURNAL_SIZE_LIMIT("journal_size_limit"),
401-
LEGACY_FILE_FORMAT("legacy_file_format", OnOff),
402-
LOCKING_MODE("locking_mode", toStringArray(LockingMode.values())),
403-
PAGE_SIZE("page_size"),
404-
MAX_PAGE_COUNT("max_page_count"),
405-
READ_UNCOMMITTED("read_uncommitted", OnOff),
406-
RECURSIVE_TRIGGERS("recursive_triggers", OnOff),
407-
REVERSE_UNORDERED_SELECTS("reverse_unordered_selects", OnOff),
408-
SECURE_DELETE("secure_delete", new String[] {"true", "false", "fast"}),
409-
SHORT_COLUMN_NAMES("short_column_names", OnOff),
410-
SYNCHRONOUS("synchronous", toStringArray(SynchronousMode.values())),
411-
TEMP_STORE("temp_store", toStringArray(TempStore.values())),
412-
TEMP_STORE_DIRECTORY("temp_store_directory"),
413-
USER_VERSION("user_version"),
414-
APPLICATION_ID("application_id"),
387+
CACHE_SIZE(
388+
"cache_size",
389+
"Maximum number of database disk pages that SQLite will hold in memory at once per open database file",
390+
null),
391+
MMAP_SIZE(
392+
"mmap_size",
393+
"Maximum number of bytes that are set aside for memory-mapped I/O on a single database",
394+
null),
395+
CASE_SENSITIVE_LIKE(
396+
"case_sensitive_like",
397+
"Installs a new application-defined LIKE function that is either case sensitive or insensitive depending on the value",
398+
OnOff),
399+
COUNT_CHANGES("count_changes", "Deprecated", OnOff),
400+
DEFAULT_CACHE_SIZE("default_cache_size", "Deprecated", null),
401+
DEFER_FOREIGN_KEYS(
402+
"defer_foreign_keys",
403+
"When the defer_foreign_keys PRAGMA is on, enforcement of all foreign key constraints is delayed until the outermost transaction is committed. The defer_foreign_keys pragma defaults to OFF so that foreign key constraints are only deferred if they are created as \"DEFERRABLE INITIALLY DEFERRED\". The defer_foreign_keys pragma is automatically switched off at each COMMIT or ROLLBACK. Hence, the defer_foreign_keys pragma must be separately enabled for each transaction. This pragma is only meaningful if foreign key constraints are enabled, of course.",
404+
OnOff),
405+
EMPTY_RESULT_CALLBACKS("empty_result_callback", "Deprecated", OnOff),
406+
ENCODING(
407+
"encoding",
408+
"Set the encoding that the main database will be created with if it is created by this session",
409+
toStringArray(Encoding.values())),
410+
FOREIGN_KEYS("foreign_keys", "Set the enforcement of foreign key constraints", OnOff),
411+
FULL_COLUMN_NAMES("full_column_names", "Deprecated", OnOff),
412+
FULL_SYNC(
413+
"fullsync",
414+
"Whether or not the F_FULLFSYNC syncing method is used on systems that support it. Only Mac OS X supports F_FULLFSYNC.",
415+
OnOff),
416+
INCREMENTAL_VACUUM(
417+
"incremental_vacuum",
418+
"Causes up to N pages to be removed from the freelist. The database file is truncated by the same amount. The incremental_vacuum pragma has no effect if the database is not in auto_vacuum=incremental mode or if there are no pages on the freelist. If there are fewer than N pages on the freelist, or if N is less than 1, or if the \"(N)\" argument is omitted, then the entire freelist is cleared.",
419+
null),
420+
JOURNAL_MODE(
421+
"journal_mode",
422+
"Set the journal mode for databases associated with the current database connection",
423+
toStringArray(JournalMode.values())),
424+
JOURNAL_SIZE_LIMIT(
425+
"journal_size_limit",
426+
"Limit the size of rollback-journal and WAL files left in the file-system after transactions or checkpoints",
427+
null),
428+
LEGACY_FILE_FORMAT("legacy_file_format", "No-op", OnOff),
429+
LOCKING_MODE(
430+
"locking_mode",
431+
"Set the database connection locking-mode",
432+
toStringArray(LockingMode.values())),
433+
PAGE_SIZE(
434+
"page_size",
435+
"Set the page size of the database. The page size must be a power of two between 512 and 65536 inclusive.",
436+
null),
437+
MAX_PAGE_COUNT(
438+
"max_page_count", "Set the maximum number of pages in the database file", null),
439+
READ_UNCOMMITTED("read_uncommitted", "Set READ UNCOMMITTED isolation", OnOff),
440+
RECURSIVE_TRIGGERS("recursive_triggers", "Set the recursive trigger capability", OnOff),
441+
REVERSE_UNORDERED_SELECTS(
442+
"reverse_unordered_selects",
443+
"When enabled, this PRAGMA causes many SELECT statements without an ORDER BY clause to emit their results in the reverse order from what they normally would",
444+
OnOff),
445+
SECURE_DELETE(
446+
"secure_delete",
447+
"When secure_delete is on, SQLite overwrites deleted content with zeros",
448+
new String[] {"true", "false", "fast"}),
449+
SHORT_COLUMN_NAMES("short_column_names", "Deprecated", OnOff),
450+
SYNCHRONOUS(
451+
"synchronous",
452+
"Set the \"synchronous\" flag",
453+
toStringArray(SynchronousMode.values())),
454+
TEMP_STORE(
455+
"temp_store",
456+
"When temp_store is DEFAULT (0), the compile-time C preprocessor macro SQLITE_TEMP_STORE is used to determine where temporary tables and indices are stored. When temp_store is MEMORY (2) temporary tables and indices are kept as if they were in pure in-memory databases. When temp_store is FILE (1) temporary tables and indices are stored in a file. The temp_store_directory pragma can be used to specify the directory containing temporary files when FILE is specified. When the temp_store setting is changed, all existing temporary tables, indices, triggers, and views are immediately deleted.",
457+
toStringArray(TempStore.values())),
458+
TEMP_STORE_DIRECTORY("temp_store_directory", "Deprecated", null),
459+
USER_VERSION(
460+
"user_version",
461+
"Set the value of the user-version integer at offset 60 in the database header. The user-version is an integer that is available to applications to use however they want. SQLite makes no use of the user-version itself.",
462+
null),
463+
APPLICATION_ID(
464+
"application_id",
465+
"Set the 32-bit signed big-endian \"Application ID\" integer located at offset 68 into the database header. Applications that use SQLite as their application file-format should set the Application ID integer to a unique integer so that utilities such as file(1) can determine the specific file type rather than just reporting \"SQLite3 Database\"",
466+
null),
415467

416468
// Limits
417469
LIMIT_LENGTH(
@@ -457,7 +509,10 @@ public static enum Pragma {
457509
null),
458510

459511
// Others
460-
TRANSACTION_MODE("transaction_mode", toStringArray(TransactionMode.values())),
512+
TRANSACTION_MODE(
513+
"transaction_mode",
514+
"Set the transaction mode",
515+
toStringArray(TransactionMode.values())),
461516
DATE_PRECISION(
462517
"date_precision",
463518
"\"seconds\": Read and store integer dates as seconds from the Unix Epoch (SQLite standard).\n\"milliseconds\": (DEFAULT) Read and store integer dates as milliseconds from the Unix Epoch (Java standard).",
@@ -470,26 +525,30 @@ public static enum Pragma {
470525
"date_string_format",
471526
"Format to store and retrieve dates stored as text. Defaults to \"yyyy-MM-dd HH:mm:ss.SSS\"",
472527
null),
473-
BUSY_TIMEOUT("busy_timeout", null),
474-
HEXKEY_MODE("hexkey_mode", toStringArray(HexKeyMode.values())),
475-
PASSWORD("password", null),
528+
BUSY_TIMEOUT(
529+
"busy_timeout",
530+
"Sets a busy handler that sleeps for a specified amount of time when a table is locked",
531+
null),
532+
HEXKEY_MODE("hexkey_mode", "Mode of the secret key", toStringArray(HexKeyMode.values())),
533+
PASSWORD("password", "Database password", null),
476534

477535
// extensions: "fake" pragmas to allow conformance with JDBC
478-
JDBC_EXPLICIT_READONLY("jdbc.explicit_readonly");
536+
JDBC_EXPLICIT_READONLY(
537+
"jdbc.explicit_readonly", "Set explicit read only transactions", null);
479538

480539
public final String pragmaName;
481540
public final String[] choices;
482541
public final String description;
483542

484-
private Pragma(String pragmaName) {
543+
Pragma(String pragmaName) {
485544
this(pragmaName, null);
486545
}
487546

488-
private Pragma(String pragmaName, String[] choices) {
547+
Pragma(String pragmaName, String[] choices) {
489548
this(pragmaName, null, choices);
490549
}
491550

492-
private Pragma(String pragmaName, String description, String[] choices) {
551+
Pragma(String pragmaName, String description, String[] choices) {
493552
this.pragmaName = pragmaName;
494553
this.description = description;
495554
this.choices = choices;
@@ -654,7 +713,7 @@ private static String[] toStringArray(PragmaValue[] list) {
654713
return result;
655714
}
656715

657-
public static enum Encoding implements PragmaValue {
716+
public enum Encoding implements PragmaValue {
658717
UTF8("'UTF-8'"),
659718
UTF16("'UTF-16'"),
660719
UTF16_LITTLE_ENDIAN("'UTF-16le'"),
@@ -666,11 +725,11 @@ public static enum Encoding implements PragmaValue {
666725

667726
public final String typeName;
668727

669-
private Encoding(String typeName) {
728+
Encoding(String typeName) {
670729
this.typeName = typeName;
671730
}
672731

673-
private Encoding(Encoding encoding) {
732+
Encoding(Encoding encoding) {
674733
this.typeName = encoding.getValue();
675734
}
676735

@@ -683,7 +742,7 @@ public static Encoding getEncoding(String value) {
683742
}
684743
}
685744

686-
public static enum JournalMode implements PragmaValue {
745+
public enum JournalMode implements PragmaValue {
687746
DELETE,
688747
TRUNCATE,
689748
PERSIST,
@@ -796,7 +855,7 @@ public void useLegacyFileFormat(boolean use) {
796855
set(Pragma.LEGACY_FILE_FORMAT, use);
797856
}
798857

799-
public static enum LockingMode implements PragmaValue {
858+
public enum LockingMode implements PragmaValue {
800859
NORMAL,
801860
EXCLUSIVE;
802861

@@ -816,10 +875,6 @@ public void setLockingMode(LockingMode mode) {
816875
setPragma(Pragma.LOCKING_MODE, mode.name());
817876
}
818877

819-
// public void setLockingMode(String databaseName, LockingMode mode) {
820-
// setPragma(databaseName, Pragma.LOCKING_MODE, mode.name());
821-
// }
822-
823878
/**
824879
* Sets the page size of the database. The page size must be a power of two between 512 and
825880
* 65536 inclusive.
@@ -891,7 +946,7 @@ public void enableShortColumnNames(boolean enable) {
891946
set(Pragma.SHORT_COLUMN_NAMES, enable);
892947
}
893948

894-
public static enum SynchronousMode implements PragmaValue {
949+
public enum SynchronousMode implements PragmaValue {
895950
OFF,
896951
NORMAL,
897952
FULL;
@@ -923,7 +978,7 @@ public void setSynchronous(SynchronousMode mode) {
923978
setPragma(Pragma.SYNCHRONOUS, mode.name());
924979
}
925980

926-
public static enum TempStore implements PragmaValue {
981+
public enum TempStore implements PragmaValue {
927982
DEFAULT,
928983
FILE,
929984
MEMORY;
@@ -947,7 +1002,7 @@ public void setHexKeyMode(HexKeyMode mode) {
9471002
setPragma(Pragma.HEXKEY_MODE, mode.name());
9481003
}
9491004

950-
public static enum HexKeyMode implements PragmaValue {
1005+
public enum HexKeyMode implements PragmaValue {
9511006
NONE,
9521007
SSE,
9531008
SQLCIPHER;
@@ -1014,7 +1069,7 @@ public void setApplicationId(int id) {
10141069
set(Pragma.APPLICATION_ID, id);
10151070
}
10161071

1017-
public static enum TransactionMode implements PragmaValue {
1072+
public enum TransactionMode implements PragmaValue {
10181073
/** @deprecated Use {@code DEFERRED} instead. */
10191074
@Deprecated
10201075
DEFFERED,
@@ -1061,7 +1116,7 @@ public TransactionMode getTransactionMode() {
10611116
return this.defaultConnectionConfig.getTransactionMode();
10621117
}
10631118

1064-
public static enum DatePrecision implements PragmaValue {
1119+
public enum DatePrecision implements PragmaValue {
10651120
SECONDS,
10661121
MILLISECONDS;
10671122

@@ -1079,7 +1134,7 @@ public void setDatePrecision(String datePrecision) {
10791134
this.defaultConnectionConfig.setDatePrecision(DatePrecision.getPrecision(datePrecision));
10801135
}
10811136

1082-
public static enum DateClass implements PragmaValue {
1137+
public enum DateClass implements PragmaValue {
10831138
INTEGER,
10841139
TEXT,
10851140
REAL;

src/test/java/org/sqlite/JDBCTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ public void shouldReturnNullIfProtocolUnhandled() throws Exception {
5252
assertThat(JDBC.createConnection("jdbc:anotherpopulardatabaseprotocol:", null)).isNull();
5353
}
5454

55+
@Test
56+
public void allDriverPropertyInfoShouldHaveADescription() throws Exception {
57+
Driver driver = DriverManager.getDriver("jdbc:sqlite:");
58+
assertThat(driver.getPropertyInfo(null, null))
59+
.allSatisfy((info) -> assertThat(info.description).isNotNull());
60+
}
61+
5562
@Test
5663
public void pragmaReadOnly() throws SQLException {
5764
SQLiteConnection connection =

0 commit comments

Comments
 (0)