@@ -21,69 +21,49 @@ A high-performance, non-blocking database driver for PostgreSQL, MySQL, and SQLi
2121
2222🏠 [ Homepage] ( https://smyrgeorge.github.io/ ) (under construction)
2323
24- ## Supported Databases
25-
26- - ` PostgreSQL `
27- - ` MySQL `
28- - ` SQLite `
24+ ### 📰 Articles
2925
30- ## Supported Targets
26+ Short deep‑dive posts covering Kotlin/Native, FFI, and Rust↔Kotlin interop used in sqlx4k:
3127
32- - jvm (only PostgreSQL and MySQL are supported at the moment)
33- - iosArm64
34- - iosSimulatorArm64
35- - androidNativeX64
36- - androidNativeArm64
37- - macosArm64
38- - macosX64
39- - linuxArm64
40- - linuxX64
41- - mingwX64
42- - wasmWasi (potential future candidate)
28+ - * Introduction to the Kotlin Native and FFI*
29+ [ Part 1] ( https://smyrgeorge.github.io/posts/sqlx4k---introduction-to-the-kotlin-native-and-ffi-part-1/ )
30+ [ Part 2] ( https://smyrgeorge.github.io/posts/sqlx4k---introduction-to-the-kotlin-native-and-ffi-part-2/ )
31+ - * Interoperability between Kotlin and Rust, using FFI*
32+ [ Part 1] ( https://smyrgeorge.github.io/posts/sqlx4k---interoperability-between-kotlin-and-rust-using-ffi-part-1/ )
33+ (Part 2 soon)
4334
4435## Features
4536
37+ - [ Supported databases] ( #supported-databases )
4638- [ Async I/O] ( #async-io )
4739- [ Connection pool and settings] ( #connection-pool )
4840- [ Acquiring and using connections] ( #acquiring-and-using-connections )
4941- [ Prepared statements (named and positional parameters)] ( #prepared-statements )
5042- [ Row mappers] ( #rowmappers )
5143- [ Transactions and coroutine TransactionContext] ( #transactions ) · [ TransactionContext (coroutines)] ( #transactioncontext-coroutines )
52- - [ Code generation: CRUD and @Repository implementations] ( #code-generation-crud-and-repository-implementations )
44+ - [ Code generation: CRUD and @Repository implementations] ( #code-generation-crud-and-repository-implementations ) · [ SQL syntax validation (compile-time) ] ( #sql-syntax-validation-compile-time )
5345- [ Database migrations] ( #database-migrations )
5446- [ PostgreSQL LISTEN/NOTIFY] ( #listennotify-only-for-postgresql )
5547- [ SQLDelight integration] ( #sqldelight )
48+ - [ Supported targets] ( #supported-targets )
5649
57- ## Usage
50+ ### Next Steps (contributions are welcome)
5851
59- ``` kotlin
60- implementation(" io.github.smyrgeorge:sqlx4k-postgres:x.y.z" )
61- // or for MySQL
62- implementation(" io.github.smyrgeorge:sqlx4k-mysql:x.y.z" )
63- // or for SQLite
64- implementation(" io.github.smyrgeorge:sqlx4k-sqlite:x.y.z" )
65- ```
66-
67- ### Windows
68-
69- If you are building your project on Windows, for target mingwX64, and you encounter the following error:
70-
71- ``` text
72- lld-link: error: -exclude-symbols:___chkstk_ms is not allowed in .drectve
73- ```
74-
75- Please look at this issue: [ #18 ] ( https://github.com/smyrgeorge/sqlx4k/issues/18 )
76-
77- ## Next Steps (contributions are welcome)
78-
79- - Enhance code-generation module.
52+ - Validate queries at compile time (avoid runtime errors)
53+ - Syntax checking is already supported (using the ` @Query ` annotation). ✅
54+ - Validate queries by accessing the DB schema
8055- Add support for SQLite JVM target.
81- - Validate queries at compile time, avoid runtime errors.
82- - WASM support.
56+ - WASM support (?).
8357- Pure Kotlin implementation for PostgreSQL.
8458- Pure Kotlin implementation for MySQL.
8559- Pure Kotlin implementation for SQLite.
8660
61+ ## Supported Databases
62+
63+ - ` PostgreSQL `
64+ - ` MySQL `
65+ - ` SQLite `
66+
8767### Async-io
8868
8969The driver is designed with full support for non-blocking I/O, enabling seamless integration with modern,
@@ -315,13 +295,19 @@ plugins {
315295 alias(libs.plugins.ksp)
316296}
317297
318- // Then you need to configure the processor (will generate the necessary code files).
298+ // Then you need to configure the processor (it will generate the necessary code files).
319299ksp {
320- // For MySQL, change the dialect to "mysql".
321- // For PostgreSQL, MariaDB, SQLite, you can skip this configuration (the "generic" dialect will be used).
300+ // Optional: pick SQL dialect for CRUD generation from @Table classes.
301+ // Currently only "mysql" is special-cased; everything else falls back to a generic ANSI-like dialect.
302+ // This setting affects the shape of INSERT/UPDATE/DELETE that TableProcessor emits.
303+ // It does NOT affect @Query validation (see notes below).
322304 // arg("dialect", "mysql")
305+
306+ // Required: where to place the generated sources.
323307 arg(" output-package" , " io.github.smyrgeorge.sqlx4k.examples.postgres" )
324- // Validates the SQL syntax in the @Query (default is true). Disable this befaviour with:
308+
309+ // Compile-time SQL syntax checking for @Query methods (default = true).
310+ // Set to "false" to turn it off if you use vendor-specific syntax not understood by the parser.
325311 // arg("validate-sql-syntax", "false")
326312}
327313
@@ -356,7 +342,7 @@ interface Sqlx4kRepository : CrudRepository<Sqlx4k> {
356342}
357343```
358344
359- > [ !NOTE]
345+ > [ !NOTE]
360346> Besides your @Query methods, because your interface extends ` CrudRepository<T> ` , the generator also adds the CRUD
361347> helper methods automatically: ` insert ` , ` update ` , ` delete ` , and ` save ` .
362348
@@ -370,7 +356,36 @@ val res: Sqlx4k = Sqlx4kRepositoryImpl.insert(db, record).getOrThrow()
370356val res: List <Sqlx4k > = Sqlx4kRepositoryImpl .selectAll(db).getOrThrow()
371357```
372358
373- For more details take a look at the ` postgres ` example.
359+ For more details take a look at the [ examples] ( ./examples ) .
360+
361+ #### SQL syntax validation (compile-time)
362+
363+ - What it is: during code generation, sqlx4k parses the SQL string in each @Query method using ` JSqlParser ` . If the
364+ parser detects a syntax error, the build fails early with a clear error message pointing to the offending repository
365+ method.
366+ - What it checks: only SQL syntax. It does not verify that tables/columns exist, parameter names match, or types are
367+ compatible.
368+ - When it runs: at KSP processing time, before your code is compiled/run.
369+ - Dialect notes: validation is dialect-agnostic and aims for an ANSI/portable subset. Some vendor-specific features
370+ (e.g., certain MySQL or PostgreSQL extensions) may not be recognized. If you hit a false positive, you can disable
371+ validation per module with ksp arg validate-sql-syntax=false.
372+ - Most reliable with: SELECT, INSERT, UPDATE, DELETE statements. DDL or very advanced constructs may not be fully
373+ supported.
374+
375+ Example of a build error you might see if your query is malformed:
376+
377+ ```
378+ > Task :compileKotlin
379+ Invalid SQL in function findAllBy: Encountered "FROMM" at line 1, column 15
380+ ```
381+
382+ Tip: keep it enabled to catch typos early; if you rely heavily on vendor-specific syntax not yet supported by the
383+ parser,
384+ turn it off with:
385+
386+ ``` kotlin
387+ ksp { arg(" validate-sql-syntax" , " false" ) }
388+ ```
374389
375390### Database Migrations
376391
@@ -407,6 +422,40 @@ db.listen("chan0") { notification: Postgres.Notification ->
407422
408423Check here: https://github.com/smyrgeorge/sqlx4k-sqldelight
409424
425+ ## Supported Targets
426+
427+ - jvm (only PostgreSQL and MySQL are supported at the moment)
428+ - iosArm64
429+ - iosSimulatorArm64
430+ - androidNativeX64
431+ - androidNativeArm64
432+ - macosArm64
433+ - macosX64
434+ - linuxArm64
435+ - linuxX64
436+ - mingwX64
437+ - wasmWasi (potential future candidate)
438+
439+ ## Usage
440+
441+ ``` kotlin
442+ implementation(" io.github.smyrgeorge:sqlx4k-postgres:x.y.z" )
443+ // or for MySQL
444+ implementation(" io.github.smyrgeorge:sqlx4k-mysql:x.y.z" )
445+ // or for SQLite
446+ implementation(" io.github.smyrgeorge:sqlx4k-sqlite:x.y.z" )
447+ ```
448+
449+ ### Windows
450+
451+ If you are building your project on Windows, for target mingwX64, and you encounter the following error:
452+
453+ ``` text
454+ lld-link: error: -exclude-symbols:___chkstk_ms is not allowed in .drectve
455+ ```
456+
457+ Please look at this issue: [ #18 ] ( https://github.com/smyrgeorge/sqlx4k/issues/18 )
458+
410459## Compilation
411460
412461You will need the ` Rust ` toolchain to build this project.
@@ -462,15 +511,24 @@ First, you need to run start-up the postgres instance.
462511docker compose up -d
463512```
464513
465- Then run the ` main ` method .
514+ And then run the examples .
466515
467516``` shell
468- ./sqlx4k-postgres-examples/build/bin/macosArm64/releaseExecutable/sqlx4k-postgres-examples.kexe
517+ # For macosArm64
518+ ./examples/postgres/build/bin/macosArm64/releaseExecutable/postgres.kexe
519+ ./examples/mysql/build/bin/macosArm64/releaseExecutable/mysql.kexe
520+ ./examples/sqlite/build/bin/macosArm64/releaseExecutable/sqlite.kexe
521+ # If you run in another platform consider running the correct tartge.
469522```
470523
471524## Examples
472525
473- See ` Main.kt ` file for more examples (examples modules).
526+ Here are small, self‑contained snippets for the most common tasks.
527+ For full runnable apps, see the modules under:
528+
529+ - PostgreSQL: [ examples/postgres] ( ./examples/postgres )
530+ - MySQL: [ examples/mysql] ( ./examples/mysql )
531+ - SQLite: [ examples/sqlite] ( ./examples/sqlite )
474532
475533## Checking for memory leaks
476534
@@ -498,16 +556,22 @@ leaks -atExit -- ./bench/postgres-sqlx4k/build/bin/macosArm64/releaseExecutable/
498556
499557## Acknowledgements
500558
501- Under the hood, ` sqlx4k ` utilizes several libraries that provide the basic access to the database functionality:
559+ sqlx4k stands on the shoulders of excellent open-source projects:
560+
561+ - Data access engines
562+ - Native targets (Kotlin/Native): sqlx (Rust)
563+ - https://github.com/launchbadge/sqlx
564+ - JVM targets:
565+ - PostgreSQL: r2dbc-postgresql
566+ - https://github.com/pgjdbc/r2dbc-postgresql
567+ - MySQL: r2dbc-mysql
568+ - https://github.com/asyncer-io/r2dbc-mysql
569+
570+ - Build-time tooling
571+ - JSqlParser — used by the code generator to parse @Query SQL at build time for syntax validation.
572+ - https://github.com/JSQLParser/JSqlParser
502573
503- - ` sqlx ` for all native targets
504- - Repository: https://github.com/launchbadge/sqlx
505- - ` r2dbc-postgresql ` for PostgreSQL on the JVM
506- - Repository: https://github.com/pgjdbc/r2dbc-postgresql
507- - ` r2dbc-mysql ` for MySQL on the JVM
508- - Repository: https://github.com/asyncer-io/r2dbc-mysql
509- - ` JSqlParser ` : for SQL syntax validation
510- - Repository: https://github.com/JSQLParser/JSqlParser
574+ Huge thanks to the maintainers and contributors of these projects.
511575
512576## License
513577
0 commit comments