yajra / laravel-oci8

Oracle DB driver for Laravel via OCI8
https://yajrabox.com/docs/laravel-oci8
MIT License
829 stars 237 forks source link

Order "compileColumnExists" by column_id #871

Closed peter1701 closed 1 month ago

peter1701 commented 1 month ago

Summary of problem or feature request

To get the columns of a table in the same order they where created in the database, it would be great to add a "order by" clause to the statement.

Code snippet of problem

It would be enough to change the method "compileColumnExists" in the file "src/Oci8/Schema/Grammars/OracleGrammar.php" from this:

    public function compileColumnExists($database, $table)
    {
        return "select column_name from all_tab_cols where upper(owner) = upper('{$database}') and upper(table_name) = upper('{$table}')";
    }

to this:

    public function compileColumnExists($database, $table)
    {
        return "select column_name from all_tab_cols where upper(owner) = upper('{$database}') and upper(table_name) = upper('{$table}') order by column_id";
    }
yajra commented 1 month ago

I tested the SQL and it looks correct as suggested. Would you mind sending a PR for this? Thanks!