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

[WIP] Working in oracle tests #1

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

[WIP] Working in oracle tests #1

wants to merge 13 commits into from

Conversation

gabolera
Copy link
Owner

@gabolera gabolera commented May 10, 2024

Environment

Knex version: latest
Database + version: Oracle 18
OS: Windows (WSL 2 / Ubuntu 22.04)

Issues Refs:

knex#4890

Initial problem!

On execute workflow on master, the tests of the oracledb driver are is disabled. you can view in here!

integration-tests.yml

https://github.com/knex/knex/blob/9659a20753e22939ffb547e3b10d5bfa6a3fd941/.github/workflows/integration-tests.yml#L92-L93

And coverage test is disabled too. coverage.yml

https://github.com/knex/knex/blob/9659a20753e22939ffb547e3b10d5bfa6a3fd941/.github/workflows/coverage.yml#L35-L36

Bugs on executed tests

On execute npm run test:oracledb has a total of 43 bugs.

+ 347 passing (8m)
  139 pending
- 43 failing

References issues finded

This issue is a list of bugs found in the tests of the oracledb driver. in here i'm explained all commits executed to solve the problems.

1 - Integration Tests > Oracledb driver tests > OracleDb unit tests > disposes the connection on connection error

Bug

AssertionError: expected 'insert into DUAL values(1) - NJS-003:…' to include 'NJS-003: invalid connection'

In official repository from node-oracledb has a commit changing this default message Commit Here


2 - Oracledb dialect > Connection configuration > knex#4869 inserting Buffer

Bug

AssertionError: expected { …(2) } to deeply equal { …(2) }
+ expected
- actual

        111
      ]]
      {
        "dir": 3003
-      "type": {
-        "_bufferSizeFactor": 112
-        "_csfrm": 0
-        "_oraTypeNum": 113
-        "columnTypeName": "BLOB"
-        "name": "DB_TYPE_BLOB"
-        "num": 2019
-      }
+      "type": 2019
      }
    ]
    "sql": "insert into \"table1\" (\"value\") values (:1) returning \"value\" into :2"
  }

Adjusted to correctly format return oracle 18c


3 - Inserts > should handle simple inserts

Bug

AssertionError: expected [ { id: '1' } ] to deeply equal [ { id: 1 } ]
+ expected
- actual

  [
    {
-    "id": "1"
+    "id": 1
    }
  ]

Fixing return id with a string because the oracle return a string when is a insert with returning.
Remove a truncate() method because the oracle clear rows but not clear the sequence, i need drop tables and recreate for pass the sequencial tests.


4 - Inserts > should handle multi inserts

Bug

AssertionError: expected [ { id: '2' }, { id: '3' } ] to deeply equal [ { id: 1 }, { id: 2 } ]
+ expected
- actual

  [
    {
-    "id": "2"
+    "id": 1
    }
    {
-    "id": "3"
+    "id": 2
    }
  ]

5 - Inserts > should allow for using the `asCallback` interface

Bug

AssertionError: expected [ { id: '1' }, { id: '2' }, …(1) ] to deeply equal [ '1', '2', '3' ]
+ expected
- actual

  [
-  {
-    "id": "1"
-  }
-  {
-    "id": "2"
-  }
-  {
-    "id": "3"
-  }
+  "1"
+  "2"
+  "3"
  ]

6 - Inserts > should take hashes passed into insert and keep them in the correct order

Bug

AssertionError: expected [ { id: '4' }, { id: '5' } ] to deeply equal [ { id: 1 }, { id: 2 } ]
+ expected
- actual

  [
    {
-    "id": "4"
+    "id": 1
    }
    {
-    "id": "5"
+    "id": 2
    }
  ]

7 - Inserts > should drop any where clause bindings

Bug

AssertionError: expected [ { id: '8' } ] to deeply equal [ [ { id: 1 } ] ]
+ expected
- actual

  [
-  {
-    "id": "8"
-  }
+  [
+    {
+      "id": 1
+    }
+  ]
  ]

8 - Inserts > should handle empty inserts

Bug

AssertionError: expected [ { id: '1' } ] to deeply equal [ { id: 1 } ]
+ expected
- actual

  [
    {
-    "id": "1"
+    "id": 1
    }
  ]

9 - Inserts > should handle empty arrays inserts

Bug

AssertionError: expected [ { id: '1' } ] to deeply equal [ { id: 1 } ]
+ expected
- actual

  [
    {
-    "id": "1"
+    "id": 1
    }
  ]

10 - Inserts > should allow a * for returning in postgres and oracle

Bug

AssertionError: expected [ { id: 5, account_id: 10, …(2) } ] to deeply equal [ { id: 1, account_id: 10, …(2) } ]
+ expected
- actual

  [
    {
      "account_id": 10
      "details": "Lorem ipsum Minim nostrud Excepteur consectetur enim ut qui sint in veniam in nulla anim do cillum sunt voluptate Duis non incididunt."
-    "id": 5
+    "id": 1
      "status": 0
    }
  ]

Tip

TODO: Review this


11 - Inserts > should replace undefined keys in multi insert with DEFAULT

Bug

Error: begin execute immediate 'insert into "accounts" ("about", "created_at", "email", "last_name", "logins", "updated_at") values (:1, :2, :3, :4, DEFAULT, :5) returning "ROWID" into :6' using :1, :2, :3, :4, :5, out :6; execute immediate 'insert into "accounts" ("about", "created_at", "email", "last_name", "logins", "updated_at") values (DEFAULT, :1, :2, :3, :4, :5) returning "ROWID" into :6' using :7, :8, :9, :10, :11, out :12;end; - NJS-098: 4 positional bind values are required but 2 were provided

Function is not working correctly, i'm removing for working correctly


12 - Additional > Custom response processing > should emit error events when a stream query fails

Bug

Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  • Solved

13 - Additional > Custom response processing > should release the connection when a stream query iteration errors

Bug

Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  • Solved

14 - Additional > Custom response processing > should process response done through a stream

Bug

Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  • Solved

15 - Additional > Custom response processing > should pass query context for responses through a stream

Bug

Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  • Solved

16 - Additional > Custom response processing > should process response for each row done through a stream

Bug

Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  • Solved

17 - Additional > other operations > should allow using .fn-methods to generate a uuid with select

Bug

Error: select (random_uuid()) as uuid - ORA-00923: FROM keyword not found where expected
Help: https://docs.oracle.com/error-help/db/ora-00923/

18 - Additional > other operations > should allow using .fn-methods to be a default value

Bug

Error: create table "default_uuid_table" ("uuid" char(36) default (random_uuid())) - ORA-04044: procedure, function, package, or type is not allowed here
Help: https://docs.oracle.com/error-help/db/ora-04044/

19 - Additional > other operations > should insert binary uuid and retrieve it with not ordered uuid data

Bug

Error: insert into "uuid_table" ("uuid_col_binary") values (:1) returning "uuid_col_binary" into :2 - ORA-00932: inconsistent datatypes: expected BLOB got BINARY
Help: https://docs.oracle.com/error-help/db/ora-00932/

20 - Additional > other operations > should insert binary uuid and retrieve it

Bug

Error: insert into "uuid_table" ("uuid_col_binary") values (:1) returning "uuid_col_binary" into :2 - ORA-00932: inconsistent datatypes: expected BLOB got BINARY
Help: https://docs.oracle.com/error-help/db/ora-00932/

21 - Joins > has a leftJoin method parameter to specify the join type

Bug

AssertionError: expected [ { id: 9, …(10) }, …(7) ] to deeply equal [ { id: 1, …(10) }, …(7) ]
+ expected
- actual

    {
      "about": "Lorem ipsum Dolore labore incididunt enim."
      "balance": 0
      "created_at": [Date: 2024-05-13T19:17:42.549Z]
-    "details": [null]
+    "details": "Lorem ipsum Minim nostrud Excepteur consectetur enim ut qui sint in veniam in nulla anim do cillum sunt voluptate Duis non incididunt."
      "email": "test1@example.com"
      "first_name": "Test"
-    "id": 9
+    "id": 1
      "last_name": "User"
      "logins": 1
      "phone": [null]
      "updated_at": [Date: 2024-05-13T19:17:42.549Z]
--
    {
      "about": "Lorem ipsum Dolore labore incididunt enim."
      "balance": 0
      "created_at": [Date: 2024-05-13T19:17:42.549Z]
-    "details": [null]
+    "details": "Lorem ipsum Minim nostrud Excepteur consectetur enim ut qui sint in veniam in nulla anim do cillum sunt voluptate Duis non incididunt."
      "email": "test2@example.com"
      "first_name": "Test"
-    "id": 10
+    "id": 2
      "last_name": "User"
      "logins": 1
      "phone": [null]
      "updated_at": [Date: 2024-05-13T19:17:42.549Z]
--
      "created_at": [Date: 2024-05-13T19:17:42.549Z]
      "details": [null]
      "email": "test3@example.com"
      "first_name": "Test"
-    "id": 11
+    "id": 3
      "last_name": "User"
      "logins": 2
      "phone": [null]
      "updated_at": [Date: 2024-05-13T19:17:42.549Z]
--
      "created_at": [Date: 2024-05-13T19:17:42.549Z]
      "details": [null]
      "email": "test4@example.com"
      "first_name": "Test"
-    "id": 12
+    "id": 4
      "last_name": "User"
      "logins": 2
      "phone": [null]
      "updated_at": [Date: 2024-05-13T19:17:42.549Z]
--
      "created_at": [Date: 2024-05-13T19:17:42.549Z]
      "details": [null]
      "email": "test5@example.com"
      "first_name": "Test"
-    "id": 13
+    "id": 5
      "last_name": "User"
      "logins": 2
      "phone": [null]
      "updated_at": [Date: 2024-05-13T19:17:42.549Z]
--
      "created_at": [Date: 2024-05-13T19:17:42.549Z]
      "details": [null]
      "email": "test6@example.com"
      "first_name": "Test"
-    "id": 14
+    "id": 6
      "last_name": "User"
      "logins": 2
      "phone": [null]
      "updated_at": [Date: 2024-05-13T19:17:42.549Z]
--
      "created_at": [Date: 2024-05-13T19:17:42.549Z]
      "details": [null]
      "email": "test7@example.com"
      "first_name": "Test2"
-    "id": 15
+    "id": 7
      "last_name": "User2"
      "logins": 2
      "phone": [null]
      "updated_at": [Date: 2024-05-13T19:17:42.549Z]
--
      "created_at": [Date: 2024-05-13T19:17:42.549Z]
      "details": [null]
      "email": "test8@example.com"
      "first_name": "Test2"
-    "id": 16
+    "id": 8
      "last_name": "User2"
      "logins": 3
      "phone": [null]
      "updated_at": [Date: 2024-05-13T19:17:42.549Z]

Change truncate to drop table for restart sequences on oracle!


22 - Joins > supports join aliases with advanced joins

Bug

AssertionError: expected [ …(5) ] to deeply equal [ …(5) ]
+ expected
- actual

      "e1": "test1@example.com"
      "e2": "test2@example.com"
    }
    {
+    "e1": "test2@example.com"
+    "e2": "test2@example.com"
+  }
+  {
      "e1": "test3@example.com"
      "e2": "test2@example.com"
    }
    {
--
    {
      "e1": "test5@example.com"
      "e2": "test2@example.com"
    }
-  {
-    "e1": "test6@example.com"
-    "e2": "test2@example.com"
-  }
  ]

23 - Joins > left join with subquery in on clause, #

Bug

AssertionError: expected false to equal true
+ expected
- actual

-false
+true
  • Solved

24 - Joins > json joins > join on json path value

Bug

Error: select "cities"."name" "cityName", "country"."name" "countryName" from "cities" inner join "country" on json_value("temperature", :1) = json_value("climate", :2) - ORA-40454: path expression not a literal
Help: https://docs.oracle.com/error-help/db/ora-40454/
  • Solved

25 - Selects > returns an array of a single column with `pluck`

Bug

AssertionError: expected [ 9, 10, 11, 12, 13, 14, 15, 16 ] to deeply equal [ 1, 2, 3, 4, 5, 6, 7, 8 ]
+ expected
- actual

  [
-  9
-  10
-  11
-  12
-  13
-  14
-  15
-  16
+  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
  ]

26 - Selects > can pluck a qualified column name, knex#1619

Bug

AssertionError: expected [ 17, 18, 19, 20, 21, 22, 23, 24 ] to deeply equal [ 1, 2, 3, 4, 5, 6, 7, 8 ]
+ expected
- actual

  [
-  17
-  18
-  19
-  20
-  21
-  22
-  23
-  24
+  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
  ]

27 - Selects > starts selecting at offset

Bug

AssertionError: expected [ 27, 28, 29, 30, 31, 32 ] to deeply equal [ 3, 4, 5, 6, 7, 8 ]
+ expected
- actual

  [
-  27
-  28
-  29
-  30
-  31
-  32
+  3
+  4
+  5
+  6
+  7
+  8
  ]

28 - Selects > knex#4199 - ignores invalid hint comments

Bug

AssertionError: expected [ { id: 49 }, { id: 50 }, …(6) ] to deeply equal [ { id: 1 }, { id: 2 }, …(6) ]
+ expected
- actual

  [
    {
-    "id": 49
+    "id": 1
    }
    {
-    "id": 50
+    "id": 2
    }
    {
-    "id": 51
+    "id": 3
    }
    {
-    "id": 52
+    "id": 4
    }
    {
-    "id": 53
+    "id": 5
    }
    {
-    "id": 54
+    "id": 6
    }
    {
-    "id": 55
+    "id": 7
    }
    {
-    "id": 56
+    "id": 8
    }
  ]

29 - Selects > returns a single entry with first

Bug

AssertionError: expected { id: 57, first_name: 'Test' } to deeply equal { id: 1, first_name: 'Test' }
+ expected
- actual

  {
    "first_name": "Test"
-  "id": 57
+  "id": 1
  }

30 - Selects > returns a stream if not passed a function

Bug

Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  • Solved

31 - Selects > emits error on the stream, if not passed a function, and query fails

Bug

Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  • Solved

32 - Selects > uses "orderBy"

Bug

AssertionError: expected [ 136, 135, 134, 133, 132, 131, …(2) ] to deeply equal [ 8, 7, 6, 5, 4, 3, 2, 1 ]
+ expected
- actual

  [
-  136
-  135
-  134
-  133
-  132
-  131
-  130
-  129
+  8
+  7
+  6
+  5
+  4
+  3
+  2
+  1
  ]

33 - Where > simple "where" cases > allows key, value

Bug

AssertionError: expected [] to deeply equal [ { first_name: 'Test', …(1) } ]
+ expected
- actual

-[]
+[
+  {
+    "first_name": "Test"
+    "last_name": "User"
+  }
+]
  • Solved

34 - Where > simple "where" cases > allows key, operator, value

Bug

AssertionError: expected [] to deeply equal [ { first_name: 'Test', …(1) } ]
+ expected
- actual

-[]
+[
+  {
+    "first_name": "Test"
+    "last_name": "User"
+  }
+]
  • Solved

35 - Where > simple "where" cases > allows a hash of where attrs

Bug

AssertionError: expected [] to deeply equal [ { id: '1', …(9) } ]
+ expected
- actual

-[]
+[
+  {
+    "about": "Lorem ipsum Dolore labore incididunt enim."
+    "balance": 0
+    "created_at": [Date: 2024-05-13T19:17:42.549Z]
+    "email": "test1@example.com"
+    "first_name": "Test"
+    "id": "1"
+    "last_name": "User"
+    "logins": 1
+    "phone": [null]
+    "updated_at": [Date: 2024-05-13T19:17:42.549Z]
+  }
+]

36 - Updates > should allow returning for updates

Bug

AssertionError: expected 81 to deeply equal 1
+ expected
- actual

-81
+1

37 - Updates > should allow returning for updates with specific transaction

Bug

AssertionError: expected 89 to deeply equal 1
+ expected
- actual

-89
+1

38 - Checks > create table with raw check on table

Bug

AssertionError: expected [ Array(1) ] to deeply equal [ Array(1) ]
+ expected
- actual

  [
-  "create table \"check_test\" (\"col1\" varchar2(255), \"col2\" varchar2(255), check (\"col1\" = \"col2\"))"
+  "create table \"check_test\" (\"name\" varchar2(255) check (\"name\" LIKE '%val%'))"
  ]

39 - Schema (misc) > createTable > sets default values with defaultTo

Bug

AssertionError: expected [ …(2) ] to deeply equal [ …(2) ]
+ expected - actual

  [
-  "create table \"test_table_three\" (\"main\" integer not null, \"paragraph\" clob default 'Lorem ipsum Qui quis qui in.', \"metadata\" varchar2(4000) default '{\"a\":10}' check (\"metadata\" is json))"
+  "create table \"test_table_three\" (\"main\" integer not null, \"paragraph\" clob default 'Lorem ipsum Qui quis qui in.', \"metadata\" clob default '{\"a\":10}')"
    "alter table \"test_table_three\" add constraint \"test_table_three_pkey\" primary key (\"main\")"
  ]
  • Solved

40 - Schema (misc) > dropTable > should drop a table

Bug

Error: drop table "test_table_three" - ORA-00942: table or view does not exist
Help: https://docs.oracle.com/error-help/db/ora-00942/
  • Solved

41 - Schema > Primary keys > createPrimaryKey > create multiple primary keys with increments on same column

Bug

Error: DECLARE PK_NAME VARCHAR(200); BEGIN  EXECUTE IMMEDIATE ('CREATE SEQUENCE "table_multiple_keys_seq"');  SELECT cols.column_name INTO PK_NAME  FROM all_constraints cons, all_cons_columns cols  WHERE cons.constraint_type = 'P'  AND cons.constraint_name = cols.constraint_name  AND cons.owner = cols.owner  AND cols.table_name = 'table_multiple_keys';  execute immediate ('create or replace trigger "table_multiple_keys_autoinc_trg"  BEFORE INSERT on "table_multiple_keys"  for each row  declare  checking number := 1;  begin    if (:new."' || PK_NAME || '" is null) then      while checking >= 1 loop        select "table_multiple_keys_seq".nextval into :new."' || PK_NAME || '" from dual;        select count("' || PK_NAME || '") into checking from "table_multiple_keys"        where "' || PK_NAME || '" = :new."' || PK_NAME || '";      end loop;    end if;  end;'); END; - ORA-01403: no data found
ORA-06512: at line 1
  • Solved

42 - Schema > Primary keys > createPrimaryKey > create multiple primary keys with increments on other columns

Bug

Error: DECLARE PK_NAME VARCHAR(200); BEGIN  EXECUTE IMMEDIATE ('CREATE SEQUENCE "table_multiple_keys_seq"');  SELECT cols.column_name INTO PK_NAME  FROM all_constraints cons, all_cons_columns cols  WHERE cons.constraint_type = 'P'  AND cons.constraint_name = cols.constraint_name  AND cons.owner = cols.owner  AND cols.table_name = 'table_multiple_keys';  execute immediate ('create or replace trigger "table_multiple_keys_autoinc_trg"  BEFORE INSERT on "table_multiple_keys"  for each row  declare  checking number := 1;  begin    if (:new."' || PK_NAME || '" is null) then      while checking >= 1 loop        select "table_multiple_keys_seq".nextval into :new."' || PK_NAME || '" from dual;        select count("' || PK_NAME || '") into checking from "table_multiple_keys"        where "' || PK_NAME || '" = :new."' || PK_NAME || '";      end loop;    end if;  end;'); END; - ORA-01403: no data found
ORA-06512: at line 1
  • Solved

43 - Views > view > create materialized view

Bug

Error: BEGIN DBMS_MVIEW.REFRESH('mat_view'); END; - ORA-20000: ORA-01031: insufficient privileges
ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 2957
ORA-06512: at "SYS.DBMS_IREFRESH", line 151
ORA-06512: at "SYS.DBMS_ISNAPSHOT", line 186
ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 2791
ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 3197
ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 3228
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 15
ORA-06512: at line 1
Help: https://docs.oracle.com/error-help/db/ora-20000/
  • Solved

truncate() only deletes lines and not sequences/incrementals, its a problem with tests
the library of `oracledb` returns ids with a string! discussion about this in knex#3134
the test failed is `should replace undefined keys in multi insert with DEFAULT`
@gabolera gabolera changed the title Oracle Working in oracle tests May 10, 2024
drop this table before because error on `test_table_two`. Error is `ORA-02449: unique/primary keys in table referenced by foreign keys`
in official repository from `node-oracledb` has a commit changing this message \n[Commit](oracle/node-oracledb@8206eb6#diff-0af7067b49efcaf7dae9a3707f2e79638b336e72780d2b834e007f80ef9a5fa0R196)
…set auto sequences

`.truncate()` in oracle clear data rows but not clear sequences that's why this tests dosen't work with oracle. let's drop table and recreate for restart sequences
@gabolera gabolera changed the title Working in oracle tests [WIP] Working in oracle tests May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant