Closed mbhd90 closed 8 years ago
Oracle's "everything is capitalized!" is clashing with Cake's auto-inflection. If you try to bake something like "SomeTable", then Cake will look for a table named "some_table". If you try to bake "USERS", then Cake will look for a table named "u_s_e_r_s".
You can overcome this first problem by simply typing the table name in lower case, e.g.
bin/cake bake all users
instead of
bin/cake bake all USERS
Sadly, even when you get past that step there are still issues. I didn't use the command-line "bake" myself, so I didn't know about this issue until now. I'll see if the subsequent errors are easy to fix.
Turns out you might not have further "bake" issues after all. The table I was testing on simply had a column with a data type ("LONG RAW") that my driver had not yet accounted for. After I added "LONG RAW" to the list of known column types, my "bake all" worked just fine for the lower-cased table name as I described before. I'll go ahead and add this new column type code to the next release
I'm also stuck on the same problem: Cannot describe {{table}}. It has 0 columns. How I can resolve this issue? Thanks.
@afedchuk Did you try the suggestion above about using the lower-case version of the table name? If your table is named "USERS", then do
bin/cake bake all Users
or
bin/cake bake all users
instead of
bin/cake bake all USERS
If your table name has underscores, like, say, "USER_PREFERENCES", then you can do either
bin/cake bake all UserPreferences
or
bin/cake bake all user_preferences
It was result on ui part when I was retrieving data from database using models created and I also tried run bake and got next result:
[root@base-rhel6u5x64 DEV]# bin/cake bake all usrs
Welcome to CakePHP v3.1.8 Console
App : src Path: /opt/app/src/ PHP : 7.0.2
Bake All
One moment while associations are detected. Your database does not have any tables.
My app config has next db configuration:
'default' => [ 'className' => 'Cake\Database\Connection', 'driver' => 'Cake\Oracle\Driver\Oracle', 'username' => 'AF_2101', 'password' => 'sa', 'database' => '(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)))(CONNECT_DATA=(SERVICE_NAME=orcl)))', 'schema' => 'AF_2101', ],
Hmm. Are your tables actually in the AF_2101 schema? A fairly common practice I've seen, especially in large corporate databases, is to have the actual data tables in a separate schema that does not allow direct logins.
If your tables are in a separate schema from your login username, then you need to either
class UsersTable extends Table
{
public function initialize(array $config)
{
$this->table('otherschema.users');
}
}
@mbhd90 FYI, I just pushed out a release (1.0.7) that attempts to compensate for the ALL_CAPS / CamelCase discrepancy between Cake and Oracle. The "Choose a model to bake" listings should now match what Cake expects.
Yes, tables in that schema. I'll try this solution, thanks for advice and your time.
Update on my issue. I did everything what you proposed for me but it didn't help for me. I also tried change different versions of oracle instance client on linux and windows but nothing, only downgrading of php from 7.0.2 to 5.6.17 version helped me. Possibly some changes in php7 affected plugin. Both version of php were compiling with the same options and downloaded from official site.
Oh, I haven't even tried testing with PHP 7. Interesting. I'll have to test that at some point.
Found at least one little issue with PHP 7 that I've fixed. I'm not sure if it'll help your issue, @afedchuk, but if you're willing to try again with 7 I'd like to know if it helps.
Now it seems is working fine on php7. Thank you @snelg
One moment while associations are detected. Exception: Cannot describe s_u_s_e_r_s. It has 0 columns. in [/var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/Database/Schema/Collection.php, line 98] 2016-01-21 12:12:27 Error: [Cake\Database\Exception] Cannot describe s_u_s_e_r_s. It has 0 columns. Stack Trace:
0 /var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/Database/Schema/CachedCollection.php(64): Cake\Database\Schema\Collection->describe('s_u_s_e_r_s', Array)
1 /var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/ORM/Table.php(423): Cake\Database\Schema\CachedCollection->describe('s_u_s_e_r_s')
2 /var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/ORM/Table.php(499): Cake\ORM\Table->schema()
3 /var/www/html/3.0/app-master/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(194): Cake\ORM\Table->primaryKey()
4 /var/www/html/3.0/app-master/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(110): Bake\Shell\Task\ModelTask->getAssociations(Object(Cake\ORM\Table))
5 /var/www/html/3.0/app-master/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(96): Bake\Shell\Task\ModelTask->bake('SUSERS')
6 /var/www/html/3.0/app-master/vendor/cakephp/bake/src/Shell/BakeShell.php(250): Bake\Shell\Task\ModelTask->main('SUSERS')
7 /var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/Collection/CollectionTrait.php(51): Bake\Shell\BakeShell->Bake\Shell{closure}('SUSERS', 0)
8 /var/www/html/3.0/app-master/vendor/cakephp/bake/src/Shell/BakeShell.php(253): Cake\Collection\Collection->each(Object(Closure))
9 [internal function]: Bake\Shell\BakeShell->all('SUSERS')
10 /var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/Console/Shell.php(443): call_user_func_array(Array, Array)
11 /var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(212): Cake\Console\Shell->runCommand(Array, true, Array)
12 /var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(179): Cake\Console\ShellDispatcher->_dispatch(Array)
13 /var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(126): Cake\Console\ShellDispatcher->dispatch(Array)
14 /var/www/html/3.0/app-master/bin/cake.php(33): Cake\Console\ShellDispatcher::run(Array)
15 {main}