Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into column_type_classes2
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Schema.php
  • Loading branch information
Tigrov committed Apr 26, 2024
2 parents 711c381 + 6710681 commit 125bb05
Show file tree
Hide file tree
Showing 32 changed files with 329 additions and 181 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/bc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on:
pull_request:
paths:
- 'src/**'
- '.github/workflows/bc.yml'
- 'composer.json'
push:
branches: ['master']
paths:
- 'src/**'
- '.github/workflows/bc.yml'
- 'composer.json'

name: backwards compatibility

jobs:
roave_bc_check:
uses: yiisoft/actions/.github/workflows/bc.yml@master
with:
os: >-
['ubuntu-latest']
php: >-
['8.1']
15 changes: 0 additions & 15 deletions .github/workflows/bc.yml_

This file was deleted.

3 changes: 1 addition & 2 deletions .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
- ubuntu-latest

php:
- 8.0
- 8.1

steps:
Expand Down Expand Up @@ -71,6 +70,6 @@ jobs:

- name: Run infection.
run: |
vendor/bin/roave-infection-static-analysis-plugin -j2 --ignore-msi-with-no-mutations --only-covered
vendor/bin/roave-infection-static-analysis-plugin --threads=2 --ignore-msi-with-no-mutations --only-covered
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
6 changes: 6 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
- '8.0'
- '8.1'
- '8.2'
- '8.3'

steps:
- name: Checkout.
Expand Down Expand Up @@ -70,4 +71,9 @@ jobs:
run: composer update --no-interaction --no-progress --optimize-autoloader --ansi

- name: Static analysis.
if: ${{ matrix.php != '8.0' }}
run: vendor/bin/psalm --config=${{ inputs.psalm-config }} --shepherd --stats --output-format=github --php-version=${{ matrix.php }}

- name: Static analysis.
if: ${{ matrix.php == '8.0' }}
run: vendor/bin/psalm --config=psalm4.xml --shepherd --stats --output-format=github --php-version=${{ matrix.php }}
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
# SQLite driver for Yii Database Change Log

## 1.0.2 under development
## 2.0.0 under development

- Enh #289: Implement `SqlParser` and `ExpressionBuilder` driver classes (@Tigrov)

## 1.2.0 March 21, 2024

- Enh #281: Remove unused code in `Command` class (@vjik)
- Enh #282: Change property `Schema::$typeMap` to constant `Schema::TYPE_MAP` (@Tigrov)
- Enh #283: Remove unnecessary check for array type in `Schema::loadTableIndexes()` (@Tigrov)
- Enh #287: Resolve deprecated methods (@Tigrov)
- Enh #288: Minor refactoring of `DDLQueryBuilder` and `Schema` (@Tigrov)

## 1.1.0 November 12, 2023

- Enh #263: Support json type (@Tigrov)
- Enh #278: Move methods from `Command` to `AbstractPdoCommand` class (@Tigrov)
- Bug #268: Fix foreign keys: support multiple foreign keys referencing to one table and possible null columns for reference (@Tigrov)
- Enh #273: Implement `ColumnSchemaInterface` classes according to the data type of database table columns
for type casting performance. Related with yiisoft/db#752 (@Tigrov)
- Bug #271: Refactor `DMLQueryBuilder`, related with yiisoft/db#746 (@Tigrov)

## 1.0.1 July 24, 2023

Expand Down
8 changes: 4 additions & 4 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Copyright © 2008 by Yii Software (https://www.yiiframework.com/)
Copyright © 2008 by Yii Software (<https://www.yiiframework.com/>)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

* Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Yii Software nor the names of its
* Neither the name of Yii Software nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

Expand Down
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,30 @@ perform advanced database operations such as joins and aggregates.

The package could be installed via composer:

```php
```shell
composer require yiisoft/db-sqlite
```

## Usage
## Documentation

For config connection to SQLite database check [Connecting SQLite](https://github.com/yiisoft/db/blob/master/docs/en/connection/sqlite.md).
English:

[Check the documentation docs](https://github.com/yiisoft/db/blob/master/docs/en/README.md) to learn about usage.
- For config connection to SQLite database check [Connecting SQLite](https://github.com/yiisoft/db/blob/master/docs/en/connection/sqlite.md)
- [Check the yiisoft/db docs](https://github.com/yiisoft/db/blob/master/docs/en/README.md) to learn about usage.

## Testing
Português - Brasil:

[Check the documentation](/docs/en/testing.md) to learn about testing.
- Para configurar a conexão com o SQLite leia [Connecting SQLite](https://github.com/yiisoft/db/blob/master/docs/pt-BR/connection/sqlite.md).
- [Confira a documentação](https://github.com/yiisoft/db/blob/master/docs/pt-BR/README.md) para aprender como usar.

Testing:

- [Internals](docs/internals.md)

## Support

If you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for that.
You may also check out other [Yii Community Resources](https://www.yiiframework.com/community).

## Support the project

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@
"forum": "https://www.yiiframework.com/forum/",
"wiki": "https://www.yiiframework.com/wiki/",
"chat": "https://t.me/yii3en",
"irc": "irc://irc.freenode.net/yii"
"irc": "ircs://irc.libera.chat:6697/yii"
},
"require": {
"php": "^8.0",
"ext-mbstring": "*",
"ext-pdo": "*",
"yiisoft/db": "^1.0",
"yiisoft/db": "^1.2",
"yiisoft/json": "^1.0"
},
"require-dev": {
"ext-json": "*",
"maglnet/composer-require-checker": "^4.2",
"phpunit/phpunit": "^9.6|^10.0",
"rector/rector": "^0.18",
"rector/rector": "^1.0",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.3|^5.6",
"vimeo/psalm": "^4.30|^5.20",
"yiisoft/aliases": "^2.0",
"yiisoft/cache-file": "^2.0",
"yiisoft/cache-file": "^3.1",
"yiisoft/json": "^1.0",
"yiisoft/var-dumper": "^1.5"
},
Expand Down
40 changes: 34 additions & 6 deletions docs/en/testing.md → docs/internals.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,47 @@
# Testing
# Internals

## Github actions

All our packages have github actions by default, so you can test your [contribution](https://github.com/yiisoft/db-sqlite/blob/master/.github/CONTRIBUTING.md) in the cloud.

> Note: We recommend pull requesting in draft mode until all tests pass.
## Docker image

For greater ease it is recommended to use docker containers, for this you can use the [docker-compose.yml](https://docs.docker.com/compose/compose-file/) file that is in the docs folder.

1. [MySQL 8](../../../docker-compose.yml)
2. [MariaDB 10.11](../../../docker-compose-mariadb.yml)

For running the docker containers you can use the following command:

MySQL 8.0.

```dockerfile
docker compose up -d
```

MariaDB 10.11.

```dockerfile
docker compose -f docker-compose-mariadb.yml up -d
```

## Unit testing

The package is tested with [PHPUnit](https://phpunit.de/).

The following steps are required to run the tests:

1. Run the docker container for the dbms.
2. Install the dependencies of the project with composer.
3. Run the tests.

```shell
vendor/bin/phpunit
```

### Mutation testing
## Mutation testing

The package tests are checked with [Infection](https://infection.github.io/) mutation framework with
[Infection Static Analysis Plugin](https://github.com/Roave/infection-static-analysis-plugin). To run it:
Expand All @@ -33,16 +60,17 @@ The code is statically analyzed with [Psalm](https://psalm.dev/). To run static

## Rector

Use [Rector](https://github.com/rectorphp/rector) to make codebase follow some specific rules or
use either newest or any specific version of PHP:
Use [Rector](https://github.com/rectorphp/rector) to make codebase follow some specific rules or
use either newest or any specific version of PHP:

```shell
./vendor/bin/rector
```

## Composer require checker
## Dependencies

This package uses [composer-require-checker](https://github.com/maglnet/ComposerRequireChecker) to check if all dependencies are correctly defined in `composer.json`.
Use [ComposerRequireChecker](https://github.com/maglnet/ComposerRequireChecker) to detect transitive
[Composer](https://getcomposer.org/) dependencies.

To run the checker, execute the following command:

Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php" failOnRisky="true" failOnWarning="true" executionOrder="default" resolveDependencies="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php" failOnRisky="true" failOnWarning="true" executionOrder="default" resolveDependencies="true" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/10.1/phpunit.xsd">
<coverage/>
<php>
<ini name="error_reporting" value="-1"/>
Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress"/>
<RiskyTruthyFalsyComparison errorLevel="suppress" />
</issueHandlers>
</psalm>
19 changes: 19 additions & 0 deletions psalm4.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress"/>
</issueHandlers>
</psalm>
5 changes: 4 additions & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
/**
* Disabled ./tests directory due to different branches with main package when testing
*/
// __DIR__ . '/tests',
]);

// register a single rule
Expand Down
1 change: 0 additions & 1 deletion src/AbstractTokenizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public function tokenize(): SqlToken
$token[] = (new SqlToken())->type(SqlToken::TYPE_STATEMENT);

$this->tokenStack->push($token[0]);
/** @psalm-var SqlToken */
$this->currentToken = $this->tokenStack->top();
$length = 0;

Expand Down
16 changes: 16 additions & 0 deletions src/Builder/ExpressionBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Db\Sqlite\Builder;

use Yiisoft\Db\Expression\AbstractExpressionBuilder;
use Yiisoft\Db\Sqlite\SqlParser;

final class ExpressionBuilder extends AbstractExpressionBuilder
{
protected function createSqlParser(string $sql): SqlParser
{
return new SqlParser($sql);
}
}
1 change: 0 additions & 1 deletion src/Builder/JsonExpressionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public function __construct(private QueryBuilderInterface $queryBuilder)
*/
public function build(ExpressionInterface $expression, array &$params = []): string
{
/** @psalm-var mixed $value */
$value = $expression->getValue();

if ($value instanceof QueryInterface) {
Expand Down
Loading

0 comments on commit 125bb05

Please sign in to comment.