snelg / cakephp-3-oracle

Oracle datasource for CakePHP 3.x
Apache License 2.0
11 stars 7 forks source link

Unsupported operand types #12

Closed nazkidd982 closed 8 years ago

nazkidd982 commented 8 years ago

I have an issue using cakephp-3-oracle where the error shown is as per below:

Error: Unsupported operand types File C:\xampp\htdocs\Cake3\sso\vendor\snelg\cakephp-3-oracle\src\Schema\OracleSchema.php Line: 153

This fatal error suddenly showed up after I clone my working web apps inside another computer. I have debug the connection to the oracle database. The connection is alright. When I checked line 153, it falls under the function convertColumnDescription. I don't know where else I can find any information, thus I send this issue here for help.

snelg commented 8 years ago

Oh, looks like I did not put in any error handling when my code finds a column type it does not recognize. Here's a quick test you can add to help me: Add a new line between the "default:" on line 149 and the "}" on line 150. The line should be

pr($field); exit();

Then copy the message you get back into this conversation. That will let me know what new column type I need to add to the code along with the error handling for any future types.

nazkidd982 commented 8 years ago

Really appreciate your fast response.

After I added the line as per advice, here is the error:

Warning (2): Illegal string offset 'DATA_TYPE' [ROOT\vendor\snelg\cakephp-3-oracle\src\Schema\OracleSchema.php, line 114]

Warning (2): Illegal string offset 'NULLABLE' [ROOT\vendor\snelg\cakephp-3-oracle\src\Schema\OracleSchema.php, line 159]

Warning (2): Illegal string offset 'DATA_DEFAULT' [ROOT\vendor\snelg\cakephp-3-oracle\src\Schema\OracleSchema.php, line 160]

Notice (8): Undefined variable: field [ROOT\vendor\snelg\cakephp-3-oracle\src\Schema\OracleSchema.php, line 160]

snelg commented 8 years ago

Oops. I managed to make a typo in that single line of code :) Change that "$field" to "$row" and try again, copying the error here.

nazkidd982 commented 8 years ago

Its OK,

Here is the error:

Warning (2): Illegal string offset 'DATA_TYPE' [ROOT\vendor\snelg\cakephp-3-oracle\src\Schema\OracleSchema.php, line 114]

ID

snelg commented 8 years ago

Hmm, now that error message looks incomplete. Either I didn't explain correctly where to put that line, or something got lost in your copy-paste here. So here's what the original code currently looks like:

            case 'BLOB':
                $field = ['type' => 'binary', 'length' => $row['DATA_LENGTH']];
                break;
            default:
        }

and here's what I need you to change that to:

            case 'BLOB':
                $field = ['type' => 'binary', 'length' => $row['DATA_LENGTH']];
                break;
            default:
/*** new code starts right here ***/
                echo "Unknown data type";
                pr($row);
                exit();
/*** new code ends ***/
        }

Let's see if that gives any more useful information. It's possible that what I think is the problem might not actually be the problem, and I'll have to figure out what else could be going wrong.

nazkidd982 commented 8 years ago

I did it like what you have advice, except there I didn't put the no 'echo "Unknown data type"' there.

here is the error screen shot after I put the code as requested.

capture

ahmyi commented 8 years ago

I came across the same problem. When cake bake I get the same error and added the missing DATA_TYPE #13 The other problem is due to dependencies towards yarja/laravel-pdo-via-oci8 latest release 1.0.3

snelg commented 8 years ago

Ooooh, got it. I hadn't done a composer update for a while, so I didn't see the difference with yajra's 1.0.3. If I can't fix that quickly, then I'll just force my package to require yajra 1.0.1

ahmyi commented 8 years ago

No problem on yajra 1.0.2

snelg commented 8 years ago

Man, that's weird. The 1.0.2 -> 1.0.3 change is tiny. I never would have thought it would cause a problem like this. Still digging.

ahmyi commented 8 years ago

I noticed too. The code will return column's name instead of array. Since the column's name is a string the switch case will throw an error due to key DATA_TYPE not set :grimacing:

nazkidd982 commented 8 years ago

I also just downgraded to yajra 1.0.2. It is working fine.

nazkidd982 commented 8 years ago

I will close the issue as it was rectified by downgrading on of the dependency for this plugin. Still, I hope there will be an update/patch to work around this issue. We wouldn't know if the update is necessary for other fixed.

Lastly, I would like to thank you for all your cooperation and support. I really do appreciate it.

Thanks a million @snelg and @ahmyi ...

snelg commented 8 years ago

Ah, there's a genuine bug in yajra 1.0.3. I'm creating and submitting a patch to him. In the meantime, I'll temporarily change the dependency in this project, like you've already done manually.

snelg commented 8 years ago

FYI, the bug in yajra's code is fixed, so I've updated this package to go back to using the latest yajra.