Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually set Types #801

Merged
merged 2 commits into from Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/phpunit.yml
Expand Up @@ -218,3 +218,68 @@ jobs:
- name: PHPUnit integration
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml

oci:
runs-on: ubuntu-latest

strategy:
# do not stop on another job's failure
fail-fast: false
matrix:
php-versions: ['7.4']
databases: ['oci']
server-versions: ['master']

name: php${{ matrix.php-versions }}-${{ matrix.databases }}-${{ matrix.server-versions }}

services:
oracle:
image: deepdiver/docker-oracle-xe-11g # "wnameless/oracle-xe-11g-r2"
ports:
- "1521:1521"

steps:
- name: Checkout server
uses: actions/checkout@v2
with:
repository: nextcloud/server
ref: ${{ matrix.server-versions }}

- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1

- name: Checkout app
uses: actions/checkout@v2
with:
path: apps/${{ env.APP_NAME }}

- name: Set up php ${{ matrix.php-versions }}
uses: "shivammathur/setup-php@v2"
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
extensions: mbstring, iconv, fileinfo, intl, oci8, zip, gd
coverage: none

- name: Set up PHPUnit
working-directory: apps/${{ env.APP_NAME }}
run: composer i

- name: Set up Nextcloud
run: |
mkdir data
./occ maintenance:install --verbose --database=oci --database-name=XE --database-host=127.0.0.1 --database-port=1521 --database-user=autotest --database-pass=owncloud --admin-user admin --admin-pass admin
php -f index.php
./occ app:enable --force ${{ env.APP_NAME }}

- name: PHPUnit
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c phpunit.xml

- name: PHPUnit integration
working-directory: apps/${{ env.APP_NAME }}
run: ./vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml
3 changes: 1 addition & 2 deletions lib/Migration/Version0010Date20190000000007.php
Expand Up @@ -24,7 +24,6 @@

namespace OCA\Forms\Migration;

use Doctrine\DBAL\Types\Types;
use OCP\DB\ISchemaWrapper;
use OCP\IConfig;
use OCP\IDBConnection;
Expand Down Expand Up @@ -64,7 +63,7 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
$schema = $schemaClosure();

if ($schema->hasTable('forms_events')) {
$schema->getTable('forms_events')->addColumn('unique', Types::INTEGER, [
$schema->getTable('forms_events')->addColumn('unique', 'integer', [
'notnull' => false,
'default' => 0,
]);
Expand Down
60 changes: 32 additions & 28 deletions lib/Migration/Version010200Date20200323141300.php
Expand Up @@ -24,7 +24,6 @@

namespace OCA\Forms\Migration;

use Doctrine\DBAL\Types\Types;
use OCP\DB\ISchemaWrapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
Expand Down Expand Up @@ -55,6 +54,11 @@ class Version010200Date20200323141300 extends SimpleMigrationStep {
'dropdown' => 'multiple_unique'
];

private const TYPE_BOOLEAN = 'boolean';
private const TYPE_INTEGER = 'integer';
private const TYPE_JSON = 'json';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-X does this even work on all dbs? at least not in our mappers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to doctrine-docs, doctrine will automatically fall back to text in case a DB does not support json. It worked flawless until now...
I just tested this branch with clean installations of all three dabase-types and it works without problems...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nickvergessen you're worrying about oracle?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we easily add testing ? Do you have a github workflow file on hand we could steal?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jotoeri can you add this test to this pr? :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, once green, you can merge! 🚀

private const TYPE_STRING = 'string';

/**
* @param IDBConnection $connection
* @param IConfig $config
Expand All @@ -77,43 +81,43 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op

if (!$schema->hasTable('forms_v2_forms')) {
$table = $schema->createTable('forms_v2_forms');
$table->addColumn('id', Types::INTEGER, [
$table->addColumn('id', self::TYPE_INTEGER, [
'autoincrement' => true,
'notnull' => true,
]);
$table->addColumn('hash', Types::STRING, [
$table->addColumn('hash', self::TYPE_STRING, [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('title', Types::STRING, [
$table->addColumn('title', self::TYPE_STRING, [
'notnull' => true,
'length' => 256,
]);
$table->addColumn('description', Types::STRING, [
$table->addColumn('description', self::TYPE_STRING, [
'notnull' => false,
'length' => 8192,
]);
$table->addColumn('owner_id', Types::STRING, [
$table->addColumn('owner_id', self::TYPE_STRING, [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('access_json', Types::JSON, [
$table->addColumn('access_json', self::TYPE_JSON, [
'notnull' => false,
]);
$table->addColumn('created', Types::INTEGER, [
$table->addColumn('created', self::TYPE_INTEGER, [
'notnull' => false,
'comment' => 'unix-timestamp',
]);
$table->addColumn('expires', Types::INTEGER, [
$table->addColumn('expires', self::TYPE_INTEGER, [
'notnull' => false,
'default' => 0,
'comment' => 'unix-timestamp',
]);
$table->addColumn('is_anonymous', Types::BOOLEAN, [
$table->addColumn('is_anonymous', self::TYPE_BOOLEAN, [
'notnull' => true,
'default' => 0,
]);
$table->addColumn('submit_once', Types::BOOLEAN, [
$table->addColumn('submit_once', self::TYPE_BOOLEAN, [
'notnull' => true,
'default' => 0,
]);
Expand All @@ -123,26 +127,26 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op

if (!$schema->hasTable('forms_v2_questions')) {
$table = $schema->createTable('forms_v2_questions');
$table->addColumn('id', Types::INTEGER, [
$table->addColumn('id', self::TYPE_INTEGER, [
'autoincrement' => true,
'notnull' => true,
]);
$table->addColumn('form_id', Types::INTEGER, [
$table->addColumn('form_id', self::TYPE_INTEGER, [
'notnull' => true,
]);
$table->addColumn('order', Types::INTEGER, [
$table->addColumn('order', self::TYPE_INTEGER, [
'notnull' => true,
'default' => 1,
]);
$table->addColumn('type', Types::STRING, [
$table->addColumn('type', self::TYPE_STRING, [
'notnull' => true,
'length' => 256,
]);
$table->addColumn('mandatory', Types::BOOLEAN, [
$table->addColumn('mandatory', self::TYPE_BOOLEAN, [
'notnull' => true,
'default' => 0,
]);
$table->addColumn('text', Types::STRING, [
$table->addColumn('text', self::TYPE_STRING, [
'notnull' => true,
'length' => 2048,
]);
Expand All @@ -151,14 +155,14 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op

if (!$schema->hasTable('forms_v2_options')) {
$table = $schema->createTable('forms_v2_options');
$table->addColumn('id', Types::INTEGER, [
$table->addColumn('id', self::TYPE_INTEGER, [
'autoincrement' => true,
'notnull' => true,
]);
$table->addColumn('question_id', Types::INTEGER, [
$table->addColumn('question_id', self::TYPE_INTEGER, [
'notnull' => true,
]);
$table->addColumn('text', Types::STRING, [
$table->addColumn('text', self::TYPE_STRING, [
'notnull' => true,
'length' => 1024,
]);
Expand All @@ -167,18 +171,18 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op

if (!$schema->hasTable('forms_v2_submissions')) {
$table = $schema->createTable('forms_v2_submissions');
$table->addColumn('id', Types::INTEGER, [
$table->addColumn('id', self::TYPE_INTEGER, [
'autoincrement' => true,
'notnull' => true,
]);
$table->addColumn('form_id', Types::INTEGER, [
$table->addColumn('form_id', self::TYPE_INTEGER, [
'notnull' => true,
]);
$table->addColumn('user_id', Types::STRING, [
$table->addColumn('user_id', self::TYPE_STRING, [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('timestamp', Types::INTEGER, [
$table->addColumn('timestamp', self::TYPE_INTEGER, [
'notnull' => false,
'comment' => 'unix-timestamp',
]);
Expand All @@ -187,17 +191,17 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op

if (!$schema->hasTable('forms_v2_answers')) {
$table = $schema->createTable('forms_v2_answers');
$table->addColumn('id', Types::INTEGER, [
$table->addColumn('id', self::TYPE_INTEGER, [
'autoincrement' => true,
'notnull' => true,
]);
$table->addColumn('submission_id', Types::INTEGER, [
$table->addColumn('submission_id', self::TYPE_INTEGER, [
'notnull' => true,
]);
$table->addColumn('question_id', Types::INTEGER, [
$table->addColumn('question_id', self::TYPE_INTEGER, [
'notnull' => true,
]);
$table->addColumn('text', Types::STRING, [
$table->addColumn('text', self::TYPE_STRING, [
'notnull' => true,
'length' => 4096,
]);
Expand Down