FluentSQL

1.5.1Open SourceCRA-ready
Sobre o projeto

Biblioteca de geração de SQL/MQL agnóstica de banco de dados para Delphi e Lazarus. API fluente e orientada a objetos para construir DML (SELECT, INSERT, UPDATE, DELETE) e DDL como strings puras — sem conexão ativa. Suporta Firebird, MySQL, PostgreSQL, MSSQL, SQLite, Oracle e MongoDB (MQL).

Linguagem
DelphiLazarus
Plataformas
🪟Windows🐧Linux🍎macOS🤖Android📱iOS
README do repositóriorecolher

FluentSQL — fluent SQL builder for Delphi & Lazarus

Delphi XE+ Lazarus Compatible License CRA-ready

🔒 Supply-chain transparency (CRA-ready): a machine-readable SBOM (CycloneDX) is published on the package portal — pubpascal.dev/packages/fluentsql · security disclosure policy in SECURITY.md · changes tracked in CHANGELOG.md.

📚 Documentation · ⬇️ Download · 🐛 Issues


🇬🇧 English

FluentSQL is a modern, high-performance database-agnostic SQL/MQL script generation library for Delphi and Lazarus. Its core contract is extremely simple: it only emits string — standard SQL scripts (or driver-specific equivalents such as MQL/JSON for MongoDB) through a robust, fluent object-oriented API (classes, interfaces, and method chaining). DML (CRUD) and DDL statements translate purely into parameterized text. There is no active database connection, no server-side execution, no database catalog introspection, and no validation inside this package. It remains completely strings-only by design, making it highly modular and ideal as a dependency for advanced Object-Relational Mappers (such as Janus).

🚀 Key Features

  • Fluent DML & DDL Builder: Construct queries (SELECT, INSERT, UPDATE, DELETE) and schema scripts (CREATE TABLE, ALTER TABLE, indices) using method chaining.
  • Database Engine Independence: Single interface query layer with serialization drivers for Firebird, MySQL, PostgreSQL, MSSQL, Oracle, SQLite, MongoDB (MQL), and more.
  • Parameterization Support: Standardized :pN / ? placeholder mapping utilizing a unified IFluentSQLParams interface.
  • Advanced SQL Construction: Full support for UNION, UNION ALL, INTERSECT statements, and bulk insert optimization (multi-value VALUES / insertMany).
  • Strings-Only by Design: 100% decoupled from active connection components, ensuring lightweight dependencies and zero database-access overhead.

🏛 Compatibility Matrix

Environment / IDE Platform / Compiler Drivers Serializer Dialects Supported
Delphi XE or superior VCL, FMX, Console (Win/Linux/macOS/iOS/Android) ✅ Yes Firebird, MySQL, PG, MSSQL, SQLite, Oracle, Mongo...
Lazarus / FreePascal LCL, Console (Cross-platform) ✅ Yes Firebird, MySQL, PG, MSSQL, SQLite, Oracle, Mongo...

🐧 Cross-Platform Build — Win32 / Win64 / Linux64 (verified)

✅ Verified 2026-06-20 in a real production backend: FluentSQL compiles clean for Win32, Win64 and Linux64 (dcclinux64) with no platform guards needed — it was already platform-neutral. macOS/iOS/Android follow from the Delphi RTL but are not build-verified here yet.

Building a consumer app for Linux64: install the Linux 64-bit platform (RAD Studio GetIt / GetItCmd -if=delphi_linux -ae), provide a Linux SDK (RAD Studio SDK Manager + PAServer, or a sysroot assembled from a WSL/Linux toolchain passed to dcclinux64 via --syslibroot / --libpath), then compile with dcclinux64.

⚙️ Installation

Install via Boss:

boss install FluentSQL

Or via pubpascal:

pubpascal install fluentsql

⚡️ Quick Start

1. DML Query Building (SELECT)

uses
  FluentSQL;

var
  SQL: string;
begin
  SQL := Query(dbnFirebird)
    .Select
    .Column('ID').Column('NOME')
    .From('CLIENTES')
    .Where('ATIVO').Equal(1)
    .AsString;

  // SQL = 'SELECT ID, NOME FROM CLIENTES WHERE ATIVO = 1'
end;

2. DDL Schema Definition (CREATE TABLE)

uses
  FluentSQL;

var
  SQL: string;
begin
  SQL := Schema(dbnPostgreSQL)
    .CreateTable('USUARIOS')
    .ColumnInteger('ID').PrimaryKey
    .ColumnVarChar('NOME', 100).NotNull
    .AsString;

  // SQL = 'CREATE TABLE USUARIOS (ID INTEGER PRIMARY KEY, NOME VARCHAR(100) NOT NULL)'
end;

🇧🇷 Português

FluentSQL é uma biblioteca moderna e de alta performance para geração de scripts SQL/MQL agnósticos a banco de dados em Delphi e Lazarus. Seu contrato principal é extremamente simples: gerar apenas string — scripts SQL padrão (ou equivalentes de driver, como MQL/JSON para MongoDB) por meio de uma API fluente orientada a objetos (classes, interfaces e encadeamento de métodos). Instruções DML (CRUD) e DDL traduzem-se estritamente em textos parametrizados. Não há conexão ativa com banco de dados, nem execução ou leitura de catálogo dentro deste pacote. Ele mantém-se apenas gerador de strings por design, sendo uma dependência ideal para Mapeadores Objeto-Relacionais (como o Janus).

🚀 Recursos Principais

  • Builder Fluente de DML & DDL: Construa consultas completas (SELECT, INSERT, UPDATE, DELETE) e scripts estruturais de schema (CREATE TABLE, ALTER TABLE, índices) de forma fluida.
  • Independência de Dialetos: Única interface geradora com serializadores nativos para Firebird, MySQL, PostgreSQL, MSSQL, Oracle, SQLite, MongoDB (MQL) e outros.
  • Suporte a Parametrização: Mapeamento padronizado de placeholders :pN / ? utilizando a interface unificada IFluentSQLParams.
  • Operações Avançadas: Suporte completo a blocos UNION, UNION ALL, INTERSECT e otimização de inserts em lote (multi-VALUES / insertMany).
  • Geração Apenas de Strings por Design: 100% desacoplado de componentes de conexão ativa, garantindo leveza e ausência de overhead de acesso de dados direto.

🏛 Matriz de Compatibilidade

Ambiente / IDE Plataforma / Compilador Serializador de Drivers Dialetos Suportados
Delphi XE ou superior VCL, FMX, Console (Win/Linux/macOS/iOS/Android) ✅ Sim Firebird, MySQL, PG, MSSQL, SQLite, Oracle, Mongo...
Lazarus / FreePascal LCL, Console (Multiplataforma) ✅ Sim Firebird, MySQL, PG, MSSQL, SQLite, Oracle, Mongo...

🐧 Build Multiplataforma — Win32 / Win64 / Linux64 (verificado)

✅ Verificado em 2026-06-20 num backend real em produção: o FluentSQL compila limpo em Win32, Win64 e Linux64 (dcclinux64), sem nenhum guard de plataforma — já era neutro. macOS/iOS/Android seguem da RTL Delphi, mas ainda não foram verificados em build aqui.

Para buildar um app consumidor no Linux64: instale a plataforma Linux 64-bit (RAD Studio GetIt / GetItCmd -if=delphi_linux -ae), forneça um SDK Linux (SDK Manager do RAD Studio + PAServer, ou um sysroot montado de um toolchain WSL/Linux passado ao dcclinux64 via --syslibroot / --libpath), e compile com dcclinux64.

⚙️ Instalação

Instale via Boss:

boss install FluentSQL

Ou via pubpascal:

pubpascal install fluentsql

⚡️ Início Rápido

1. Construindo Consultas DML (SELECT)

uses
  FluentSQL;

var
  SQL: string;
begin
  SQL := Query(dbnFirebird)
    .Select
    .Column('ID').Column('NOME')
    .From('CLIENTES')
    .Where('ATIVO').Equal(1)
    .AsString;

  // SQL = 'SELECT ID, NOME FROM CLIENTES WHERE ATIVO = 1'
end;

2. Definindo Schemas DDL (CREATE TABLE)

uses
  FluentSQL;

var
  SQL: string;
begin
  SQL := Schema(dbnPostgreSQL)
    .CreateTable('USUARIOS')
    .ColumnInteger('ID').PrimaryKey
    .ColumnVarChar('NOME', 100).NotNull
    .AsString;

  // SQL = 'CREATE TABLE USUARIOS (ID INTEGER PRIMARY KEY, NOME VARCHAR(100) NOT NULL)'
end;

⛏️ Contributing / Contribuição

Contributions are welcome — whether it's a bug report, a new dialect driver, or a documentation improvement. Open an issue first so we can align on scope before you start coding.

Contribuições são bem-vindas — seja um relatório de bug, um novo driver de dialeto ou melhoria na documentação. Abra uma issue primeiro para alinharmos o escopo antes de codificar.

Issues

Steps / Passos:

  1. Fork the repository / Faça um fork do repositório.
  2. Create a feature branch: git checkout -b feat/my-feature.
  3. Commit your changes following the existing style / Faça commit seguindo o estilo existente.
  4. Open a Pull Request against main with a clear description / Abra um Pull Request contra main com descrição clara.
  5. Wait for review and address any feedback / Aguarde a revisão e responda ao feedback.

📬 Contact / Contato

Email


💲 Donation / Doação

If FluentSQL saves you time, consider supporting its development. Se o FluentSQL economiza seu tempo, considere apoiar seu desenvolvimento.

Doação


📄 License / Licença

This project is distributed under the MIT License. Este projeto é distribuído sob a Licença MIT.

Copyright © 2025-2026 Isaque Pinheiro.