Skip to content

Commit 877d929

Browse files
docs: improve and modernize documentation and consistently switch to US English (#273)
1 parent 03028e9 commit 877d929

File tree

113 files changed

+327
-240
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+327
-240
lines changed

.coderabbit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ reviews:
1212
high_level_summary: true
1313
path_instructions:
1414
- path: "tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/**/*.php"
15-
instructions: "Use the online PostgreSQL's official documentation to check that the tests have comprehensive use-cases and example SQL queries for the tested SQL functions and operators."
15+
instructions: "Use the PostgreSQL official documentation to verify that tests include comprehensive use cases and example SQL queries for the tested SQL functions and operators."
1616
poem: true
1717
profile: "chill"
1818
request_changes_workflow: true

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
github: [martin-georgiev]
2+
custom: ["https://github.com/sponsors/martin-georgiev"]

README.md

Lines changed: 94 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,110 @@
22
[![Coverage Status](https://coveralls.io/repos/github/martin-georgiev/postgresql-for-doctrine/badge.svg?branch=main)](https://coveralls.io/github/martin-georgiev/postgresql-for-doctrine?branch=main)
33
[![Latest Stable Version](https://poser.pugx.org/martin-georgiev/postgresql-for-doctrine/version)](https://packagist.org/packages/martin-georgiev/postgresql-for-doctrine)
44
[![Total Downloads](https://poser.pugx.org/martin-georgiev/postgresql-for-doctrine/downloads)](https://packagist.org/packages/martin-georgiev/postgresql-for-doctrine)
5-
----
6-
## What's this?
7-
This package provides Doctrine support for some specific PostgreSQL 9.4+ features:
85

9-
* Support of JSONB and some array data-types (at present integers, BOOL, TEXT and JSONB)
10-
* Implementation of the most commonly used functions and operators when working with array and JSON data-types
11-
* Functions for text search
12-
* Aggregate functions
13-
* Date functions
6+
# PostgreSQL for Doctrine
147

15-
It can be integrated in a simple manner with Symfony, Laravel and other frameworks that make use of Doctrine.
8+
Enhances Doctrine with PostgreSQL-specific features and functions. Supports PostgreSQL 9.4+ and PHP 8.1+.
169

17-
You can easily extend package's behaviour with your own array-like data-types or other desired functions. Read more about this in the [contributing guide](docs/CONTRIBUTING.md).
10+
## Quick Start
1811

19-
----
20-
## What is available?
21-
Full set of the available types can be found [here](docs/AVAILABLE-TYPES.md).
12+
```php
13+
// Register types with Doctrine
14+
Type::addType('jsonb', "MartinGeorgiev\\Doctrine\\DBAL\\Types\\Jsonb");
15+
Type::addType('text[]', "MartinGeorgiev\\Doctrine\\DBAL\\Types\\TextArray");
2216

23-
Full set of the available functions and extra operators can be found [here](docs/AVAILABLE-FUNCTIONS-AND-OPERATORS.md).
17+
// Use in your Doctrine entities
18+
#[ORM\Column(type: 'jsonb')]
19+
private array $data;
2420

25-
----
26-
## How to install?
27-
Easiest and recommended way is with [Composer](https://getcomposer.org/download/)
21+
#[ORM\Column(type: 'text[]')]
22+
private array $tags;
2823

29-
composer require martin-georgiev/postgresql-for-doctrine
24+
// Use in DQL
25+
$query = $em->createQuery('
26+
SELECT e
27+
FROM App\Entity\Post e
28+
WHERE CONTAINS(e.tags, ARRAY[:tags]) = TRUE
29+
AND JSON_GET_FIELD(e.data, :field) = :value
30+
');
31+
```
3032

31-
----
32-
## How to integrate with your framework?
33-
Read the guide with examples for [Symfony](docs/INTEGRATING-WITH-SYMFONY.md).
33+
## 🚀 Features Highlight
3434

35-
Read the guide with examples for [Laravel](docs/INTEGRATING-WITH-LARAVEL.md).
35+
This package provides comprehensive Doctrine support for PostgreSQL features:
3636

37-
Read the guide with examples for [Doctrine](docs/INTEGRATING-WITH-DOCTRINE.md).
37+
### Data Types
38+
- **Array Types**
39+
- Integer arrays (`int[]`, `smallint[]`, `bigint[]`)
40+
- Text arrays (`text[]`)
41+
- Boolean arrays (`bool[]`)
42+
- JSONB arrays (`jsonb[]`)
43+
- **JSON Types**
44+
- Native JSONB support
45+
- JSON field operations
46+
- JSON construction and manipulation
3847

39-
----
48+
### PostgreSQL Operators
49+
- **Array Operations**
50+
- Contains (`@>`)
51+
- Is contained by (`<@`)
52+
- Overlaps (`&&`)
53+
- Array aggregation with ordering
54+
- **JSON Operations**
55+
- Field access (`->`, `->>`)
56+
- Path operations (`#>`, `#>>`)
57+
- JSON containment and existence operators
4058

41-
Check for [common use-cases, examples and known errors](docs/USE-CASES-AND-EXAMPLES.md).
59+
### Functions
60+
- **Text Search**
61+
- Full text search (`to_tsvector`, `to_tsquery`)
62+
- Pattern matching (`ILIKE`, `SIMILAR TO`)
63+
- Regular expressions
64+
- **Array Functions**
65+
- Array aggregation (`array_agg`)
66+
- Array manipulation (`array_append`, `array_prepend`)
67+
- Array dimensions and length
68+
- **JSON Functions**
69+
- JSON construction (`json_build_object`, `jsonb_build_object`)
70+
- JSON manipulation and transformation
71+
- **Date Functions**
72+
- **Aggregate Functions**
4273

43-
----
44-
## License
45-
This package is licensed under the MIT License.
74+
Full documentation:
75+
- [Available Types](docs/AVAILABLE-TYPES.md)
76+
- [Available Functions and Operators](docs/AVAILABLE-FUNCTIONS-AND-OPERATORS.md)
77+
- [Common Use Cases and Examples](docs/USE-CASES-AND-EXAMPLES.md)
78+
79+
## 📦 Installation
80+
81+
```bash
82+
composer require martin-georgiev/postgresql-for-doctrine
83+
```
84+
85+
## 🔧 Integration Guides
86+
87+
- [Integrating with Symfony](docs/INTEGRATING-WITH-SYMFONY.md)
88+
- [Integrating with Laravel](docs/INTEGRATING-WITH-LARAVEL.md)
89+
- [Integrating with Doctrine](docs/INTEGRATING-WITH-DOCTRINE.md)
90+
91+
## 💡 Usage Examples
92+
See our [Common Use Cases and Examples](docs/USE-CASES-AND-EXAMPLES.md) for detailed code samples.
93+
94+
## ⭐ Support the Project
95+
96+
### 💖 GitHub Sponsors
97+
If you find this package useful for your projects, please consider [sponsoring the development via GitHub Sponsors](https://github.com/sponsors/martin-georgiev). Your support helps maintain this package, create new features, and improve documentation.
98+
99+
Benefits of sponsoring:
100+
- Priority support for issues and feature requests
101+
- Direct access to the maintainer
102+
- Help sustain open-source development
103+
104+
### Other Ways to Help
105+
- Star the repository
106+
- [Report issues](https://github.com/martin-georgiev/postgresql-for-doctrine/issues)
107+
- [Contribute](docs/CONTRIBUTING.md) with code or documentation
108+
- Share the project with others
109+
110+
## 📝 License
111+
This package is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

docs/CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**Before opening your first PR**
44

5-
For the sake of clear Git history and speedy review of your PR please check that the suggested changes are in line with the project's standards. Code style, static analysis and file validation scripts are already provided and can easily be checked with running from project's root:
5+
For the sake of clear Git history and speedy review of your PR, please check that the suggested changes are in line with the project's standards. Code style, static analysis and file validation scripts are already provided and can easily be run from project's root:
66

77
`composer check-code-style` which will check for consistent code style
88

@@ -33,7 +33,7 @@ For the sake of clear Git history and speedy review of your PR please check that
3333

3434
Most new functions will likely have a signature very similar to those already implemented in the project. This means new functions probably require only extending the base class and decorating it with some behaviour. Here are the two main steps to follow:
3535
1. Extend `MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseFunction`.
36-
2. Use calls to `setFunctionPrototype()` and `addNodeMapping()` to implement `customiseFunction()` for your new function class.
36+
2. Use calls to `setFunctionPrototype()` and `addNodeMapping()` to implement `customizeFunction()` for your new function class.
3737

3838
Example:
3939

@@ -46,7 +46,7 @@ namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions;
4646

4747
class ArrayAppend extends BaseFunction
4848
{
49-
protected function customiseFunction(): void
49+
protected function customizeFunction(): void
5050
{
5151
$this->setFunctionPrototype('array_append(%s, %s)');
5252
$this->addNodeMapping('StringPrimary'); # corresponds to param №1 in the prototype set in setFunctionPrototype

docs/USE-CASES-AND-EXAMPLES.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
Clarification on usage of `ILIKE`, `CONTAINS`, `IS_CONTAINED_BY`, `DATE_OVERLAPS` and some other operator-like functions
22
---
33

4-
`Error: Expected =, <, <=, <>, >, >=, !=, got 'ILIKE'"` (or similar) is probably one of the most common DQL errors you may experience when working with this library. The cause for is that when parsing the DQL Doctrine won't recognise `ILIKE` as a known operator. In fact `ILIKE` is registered as a boolean function.
4+
`Error: Expected =, <, <=, <>, >, >=, !=, got 'ILIKE'"` (or similar) is probably one of the most common DQL errors you may experience when working with this library. The cause for is that when parsing the DQL Doctrine won't recognize `ILIKE` as a known operator. In fact `ILIKE` is registered as a boolean function.
55
Doctrine doesn't provide easy support for implementing custom operators. This may change in the future but for now it is easier to trick the DQL parser with a boolean expression.
66

7-
Example intent with DQL:
7+
Example intent with PostgreSQL:
8+
```sql
9+
SELECT * FROM emails WHERE subject ILIKE 'Test email';
10+
```
11+
12+
Intuitively, one may assume the below DQL. However it will not work:
813
```sql
914
SELECT e
1015
FROM EmailEntity e
1116
WHERE e.subject ILIKE 'Test email'
1217
```
1318

14-
Boolean expression that will parse and is equivalent to the above DQL:
19+
The correct DQL is with a boolean expression that will parse correctly and can look like this:
1520
```sql
1621
SELECT e
1722
FROM EmailEntity e

src/MartinGeorgiev/Doctrine/DBAL/Types/BaseArray.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Doctrine\DBAL\Types\ConversionException;
99

1010
/**
11-
* Abstract handling of PostgreSql array data types.
11+
* Abstract handling of PostgreSQL array data types.
1212
*
1313
* @see https://www.postgresql.org/docs/9.4/static/arrays.html
1414
* @since 0.1
@@ -18,7 +18,7 @@
1818
abstract class BaseArray extends BaseType
1919
{
2020
/**
21-
* Converts a value from its PHP representation to its PostgreSql representation of the type.
21+
* Converts a value from its PHP representation to its PostgreSQL representation of the type.
2222
*
2323
* @param array|null $phpArray the value to convert
2424
*
@@ -38,7 +38,7 @@ public function convertToDatabaseValue($phpArray, AbstractPlatform $platform): ?
3838

3939
foreach ($phpArray as &$item) {
4040
if (!$this->isValidArrayItemForDatabase($item)) {
41-
$exceptionMessage = 'One or more of items given doesn\'t look like valid.';
41+
$exceptionMessage = 'One or more of the items given doesn\'t look valid.';
4242

4343
throw new ConversionException($exceptionMessage);
4444
}
@@ -49,15 +49,15 @@ public function convertToDatabaseValue($phpArray, AbstractPlatform $platform): ?
4949
}
5050

5151
/**
52-
* Tests if given PHP array item is from compatible type for PostgreSql.
52+
* Tests if given PHP array item is from compatible type for PostgreSQL.
5353
*/
5454
protected function isValidArrayItemForDatabase(mixed $item): bool
5555
{
5656
return true;
5757
}
5858

5959
/**
60-
* Transforms PHP array item to a PostgreSql compatible array item.
60+
* Transforms PHP array item to a PostgreSQL compatible array item.
6161
*
6262
* @return mixed
6363
*/
@@ -67,7 +67,7 @@ protected function transformArrayItemForPostgres(mixed $item)
6767
}
6868

6969
/**
70-
* Converts a value from its PostgreSql representation to its PHP representation of this type.
70+
* Converts a value from its PostgreSQL representation to its PHP representation of this type.
7171
*
7272
* @param string|null $postgresArray the value to convert
7373
*/
@@ -77,7 +77,7 @@ public function convertToPHPValue($postgresArray, AbstractPlatform $platform): ?
7777
return null;
7878
}
7979
if (!\is_string($postgresArray)) {
80-
$exceptionMessage = 'Given PostgreSql value content type is not PHP string. Instead it is "%s".';
80+
$exceptionMessage = 'Given PostgreSQL value content type is not PHP string. Instead it is "%s".';
8181

8282
throw new ConversionException(\sprintf($exceptionMessage, \gettype($postgresArray)));
8383
}
@@ -101,7 +101,7 @@ protected function transformPostgresArrayToPHPArray(string $postgresArray): arra
101101
}
102102

103103
/**
104-
* Transforms PostgreSql array item to a PHP compatible array item.
104+
* Transforms PostgreSQL array item to a PHP compatible array item.
105105
*
106106
* @return mixed
107107
*/

src/MartinGeorgiev/Doctrine/DBAL/Types/BigIntArray.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace MartinGeorgiev\Doctrine\DBAL\Types;
66

77
/**
8-
* Implementation of PostgreSql BIGINT[] data type.
8+
* Implementation of PostgreSQL BIGINT[] data type.
99
*
1010
* @see https://www.postgresql.org/docs/9.4/static/arrays.html
1111
* @since 0.1

src/MartinGeorgiev/Doctrine/DBAL/Types/BooleanArray.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Doctrine\DBAL\Platforms\AbstractPlatform;
88

99
/**
10-
* Implementation of PostgreSql BOOL[] data type.
10+
* Implementation of PostgreSQL BOOL[] data type.
1111
*
1212
* @see https://www.postgresql.org/docs/9.4/static/arrays.html
1313
* @since 1.5.3

src/MartinGeorgiev/Doctrine/DBAL/Types/Exceptions/UnexpectedTypeOfTransformedPHPValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class UnexpectedTypeOfTransformedPHPValue extends TypeException
1414
public function __construct(string $untransformedValue, string $typeOfTransformedPHPValue)
1515
{
1616
$message = \sprintf(
17-
'Transforming a PostgreSql value "%s" results to an unexpected PHP value from type "%s".',
17+
'Transforming a PostgreSQL value "%s" results to an unexpected PHP value from type "%s".',
1818
$untransformedValue,
1919
$typeOfTransformedPHPValue
2020
);

src/MartinGeorgiev/Doctrine/DBAL/Types/IntegerArray.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace MartinGeorgiev\Doctrine\DBAL\Types;
66

77
/**
8-
* Implementation of PostgreSql INTEGER[] data type.
8+
* Implementation of PostgreSQL INTEGER[] data type.
99
*
1010
* @see https://www.postgresql.org/docs/9.4/static/arrays.html
1111
* @since 0.1

0 commit comments

Comments
 (0)