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

ORA-01790 on mass insert or update with version 6.0.x #558

Closed
basjansen126 opened this issue Feb 6, 2020 · 4 comments · Fixed by #612
Closed

ORA-01790 on mass insert or update with version 6.0.x #558

basjansen126 opened this issue Feb 6, 2020 · 4 comments · Fixed by #612

Comments

@basjansen126
Copy link

The problem

Whenever a mass insert is called (through a model or the query builder) oracle throws the following error:

ORA-01790: expression must have same datatype as corresponding expression

The problem here is that I am trying to insert data into a table with a column that accepts either an integer or null.

For example:
I have a table with people. The job_id attribute can be null or an integer.
The job_id attribute on my Person in the first case is null.
The job_id attribute on my Person in the second case is some id.
Due to not being the same data type the ORA-01790 exception is thrown, even if my job_id column can be either null or an integer.

Example of code which results in an error:

$newPeople = [
    [
         'name' => 'Foo'
         'job_id' => null,
    ],
    [
         'name' => 'Bar',
         'job_id' => 1,
    ],
    [
         'name' => 'Test',
         'job_id' => 2,
    ]
];

Then:

DB::table('people')->insert($newPeople);

OR

$person = new Person();
$person->insert($newPeople);

This has been occurring since updating to 6.0.x.
Version 5.8.x does not have this problem.

System details

  • Ubuntu 18.04.1
  • PHP 7.2.15
  • Laravel 6.0
  • Laravel-OCI8 6.0.4
@yajra
Copy link
Owner

yajra commented Feb 11, 2020

Thanks for reporting, I was able to replicate the issue now. If you can, please do not hesitate to submit a PR for a Fix.

yajra added a commit that referenced this issue Feb 11, 2020
@yajra yajra mentioned this issue Feb 11, 2020
@yajra
Copy link
Owner

yajra commented Feb 11, 2020

This has been occurring since updating to 6.0.x.
Version 5.8.x does not have this problem.

Are you sure the issue only exists on 6.x? I think the problem is with the current implementation where batch insert uses UNION sql which I think was implemented since 5.x. Anyways, will check again further when I got the chance.

-- Edit --
Found in commit history that I made some modifications when binding the values and that causes this issue.

@yajra yajra removed the for review label Feb 11, 2020
@basjansen126
Copy link
Author

Thanks for finding the issue! Hopefully it will be easy to resolve.

For now I have added a workaround in my own code so the error will not get triggered. This is okay for short term, but in the long run I would like to be able to use insert() again.

yajra added a commit that referenced this issue Dec 6, 2020
@yajra yajra closed this as completed in #612 Dec 6, 2020
yajra added a commit that referenced this issue Dec 6, 2020
* 8.x:
  Bump v8.2.1 🚀
  Add model insert tests.
  Add test for single insert.
  Fix binding values.
  Add failing tests for #558.
  Bump v8.2.0 🚀
  Fix cs.
  Fix pagination tests.
  Enhance pagination as suggested on #563.
  Fix docs.
  Bump v8.1.3 🚀
  Apply fixes from StyleCI
  Compare using actual db count.
  Use lower column name on column listing.
  Fix test suffix.
  Add failing tests for #596.
@yajra
Copy link
Owner

yajra commented Dec 6, 2020

Fixed on v8.2.1 🚀

@github-actions github-actions bot locked and limited conversation to collaborators Oct 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants