https://github.com/hashload/cqlbr
CQLBr Framework for Delphi/Lazarus (Isaque Pinheiro)
https://github.com/hashload/cqlbr
Last synced: 4 months ago
JSON representation
CQLBr Framework for Delphi/Lazarus (Isaque Pinheiro)
- Host: GitHub
- URL: https://github.com/hashload/cqlbr
- Owner: HashLoad
- Created: 2022-06-07T16:12:29.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-10-26T16:06:48.000Z (over 1 year ago)
- Last Synced: 2024-04-14T00:25:40.369Z (about 1 year ago)
- Language: Pascal
- Homepage: https://www.isaquepinheiro.com.br
- Size: 1.95 MB
- Stars: 19
- Watchers: 9
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CQLBr Library for Delphi/Lazarus
Criteria Query Language is a library that provides writing through an interface, allowing the mapping of object-oriented syntax for performing database query, insert, update, and delete operations.
During software development, there is a clear concern about increasing productivity and maintaining compatibility. Regarding databases, in most cases, there is a compatibility break due to the need to write syntax that becomes specific to a particular database. This is where CQLBr comes in. It is designed so that query writing is unique for all databases. When generating a query with CQLBr, it allows you to switch between databases in a system without having to rewrite queries with specific details of the replaced database.
## 🏛 Delphi versions
Embarcadero Delphi XE and above.## ⚙️ Install
Installation using [`boss install`]
```sh
boss install cqlbr
```## ⚡️ How to use
### SELECT
```Delphi
///
/// SELECT * FROM CLIENTES WHERE (ID_CLIENTE = 1) AND (ID >= 10) AND (ID <= 20)
///
TCQL.New(dbnFirebird)
.Select
.All
.From('CLIENTES')
.Where('ID_CLIENTE = 1')
.&And('ID').GreaterEqThan(10)
.&And('ID').LessEqThan(20)
.AsString;
///
/// SELECT ID_CLIENTE, NOME_CLIENTE, (CASE TIPO_CLIENTE WHEN 0 THEN ''FISICA'' WHEN 1 THEN ''JURIDICA'' ELSE ''PRODUTOR'' END) AS TIPO_PESSOA FROM CLIENTES;
///
TCQL.New(dbnFirebird)
.Select
.Column('ID_CLIENTE')
.Column('NOME_CLIENTE')
.Column('TIPO_CLIENTE')
.&Case
.When('0').&Then(CQL.Q('FISICA'))
.When('1').&Then(CQL.Q('JURIDICA'))
.&Else('''PRODUTOR''')
.&End
.&As('TIPO_PESSOA')
.From('CLIENTES')
.AsString);
///
/// 'SELECT * FROM CLIENTES WHERE (NOME LIKE ''%VALUE%'')';
///
TCQL.New(dbnFirebird)
.Select
.All
.From('CLIENTES')
.Where('NOME').LikeFull('VALUE')
.AsString);
///
/// 'SELECT * FROM CLIENTES WHERE (VALOR IN (1, 2, 3))';
///
TCQL.New(dbnFirebird)
.Select
.All
.From('CLIENTES')
.Where('VALOR').&In([1, 2, 3])
.AsString);///
/// 'SELECT * FROM CLIENTES WHERE (NOT EXISTS (SELECT IDCLIENTE FROM PEDIDOS WHERE (PEDIDOS.IDCLIENTE = CLIENTES.IDCLIENTE)))';
///
TCQL.New(dbnFirebird)
.Select
.All
.From('CLIENTES')
.Where.NotExists( TCQL.New(dbnFirebird)
.Select
.Column('IDCLIENTE')
.From('PEDIDOS')
.Where('PEDIDOS.IDCLIENTE').Equal('CLIENTES.IDCLIENTE')
.AsString)
.AsString);
```### INSERT
```Delphi
///
/// 'INSERT INTO CLIENTES (ID_CLIENTE, NOME_CLIENTE) VALUES (''1'', ''MyName'')';
///
TCQL.New(dbnFirebird)
.Insert
.Into('CLIENTES')
.&Set('ID_CLIENTE', '1')
.&Set('NOME_CLIENTE', 'MyName')
.AsString);
```### UPDATE
```Delphi
///
/// 'UPDATE CLIENTES SET ID_CLIENTE = ''1'', NOME_CLIENTE = ''MyName'' WHERE ID_CLIENTE = 1';
///
TCQL.New(dbnFirebird)
.Update('CLIENTES')
.&Set('ID_CLIENTE', '1')
.&Set('NOME_CLIENTE', 'MyName')
.Where('ID_CLIENTE = 1')
.AsString);
```### DELETE
```Delphi
///
/// 'DELETE FROM CLIENTES WHERE ID_CLIENTE = 1';
///
TCQL.New(dbnFirebird)
.Delete
.From('CLIENTES')
.Where('ID_CLIENTE = 1')
.AsString);
```## ✍️ License
[](https://opensource.org/licenses/LGPL-3.0)## ⛏️ Contribution
Our team would love to receive contributions to this open-source project. If you have any ideas or bug fixes, feel free to open an issue or submit a pull request..
[](https://github.com/HashLoad/ormbr/issues)
To submit a pull request, follow these steps:
1. Fork the project
2. Create a new branch (`git checkout -b my-new-feature`)
3. Make your changes and commit (`git commit -am 'Adding new feature'`)
4. Push the branch (`git push origin my-new-feature`)
5. Open a pull request.## 📬 Contact
[](https://t.me/hashload)## 💲 Donation
[](https://pag.ae/bglQrWD)