[BETA] Error: No "CREATE TABLE.." were found, please check your sql. #990

Closed
opened 2023-04-11 21:49:42 +00:00 by oxido · 7 comments

Steps to reproduce the issue

In JCB, create a new component or use an existing one
Grab a sql dump, the part that creat a table.
In JCB go to "Dynamic Build (beta)" tab, paste your sql

I even use sql dump from joomla table, same result.

Expected result

To save without any error :P

Actual result

Error No "CREATE TABLE.." were found, please check your sql.

System information (as much as possible)

  • OS Name & Version: Linux
  • MySql Version: 10.3.37-MariaDB
  • Apache Version:
  • PHP Version: 7.4.33
  • Joomla Version: Joomla! 3.10.11
  • JCB Version: 3.1.19
  • Browser: Google Chrome

Additional comments

### Steps to reproduce the issue In JCB, create a new component or use an existing one Grab a sql dump, the part that creat a table. In JCB go to "Dynamic Build (beta)" tab, paste your sql I even use sql dump from joomla table, same result. ### Expected result To save without any error :P ### Actual result Error No "CREATE TABLE.." were found, please check your sql. ### System information (as much as possible) - OS Name & Version: Linux - MySql Version: 10.3.37-MariaDB - Apache Version: - PHP Version: 7.4.33 - Joomla Version: Joomla! 3.10.11 - JCB Version: 3.1.19 - Browser: Google Chrome ### Additional comments
Owner

This sometime happen when the database is not updated as it should be, please watch these tutorials to help resolve the issue manually:

image

And possibly these:
https://youtu.be/bRPJTRat158
https://youtu.be/ZxC6z701ixA

This sometime happen when the database is not updated as it should be, please watch these tutorials to help resolve the issue manually: [![image](/attachments/eed6bc8a-9bd2-4a4f-9b41-0db65c5e9235)](https://youtu.be/55U8FDlLI7Q) And possibly these: https://youtu.be/bRPJTRat158 https://youtu.be/ZxC6z701ixA
Author

I checked the youtube videos indicated by you, my problem does not appear when I compile the component and try to install it.
The problem for me occurs when I try to create a back-end/admin view based on the structure of a database, using JCB > Demo Component > Dynamic Build (beta)[tab] > Build Backend-views Dynamically.

If I'm wrong, I apologize and please tell me if there's anything else I need to check, or I'll watch the previous videos again, maybe I didn't understand what I should do.

I checked the youtube videos indicated by you, my problem does not appear when I compile the component and try to install it. The problem for me occurs when I try to create a back-end/admin view based on the structure of a database, using JCB > Demo Component > Dynamic Build (beta)[tab] > Build Backend-views Dynamically. If I'm wrong, I apologize and please tell me if there's anything else I need to check, or I'll watch the previous videos again, maybe I didn't understand what I should do.
Owner

Okay, it seems I did not understand where you are getting this error. I must admit I have not used or worked with that area in years. It is a part of JCB that is due a major upgrade, overall improvement. That was a beta area, and it has never been brought to stable.

Ideally the plan was that it can from an existing Joomla Component setup all your boilerplate things like fields and the basic relationships. Yet there has been little insert and even less supporting programmers to help move that forward.

At this time I am overloaded with moving JCB to Joomla 4, and honestly I will have to see when I get time to look at this, unless your willing to get your hands dirty and jump in to debug things... I am not sure there will be any thing I can do soon to help.

Yet if your can kinda boil it down to where the issue is and by doing so save me the time... I will be willing to help.

Quick side note, JCB does not work in Google Chrome, but must run in Firefox.

Okay, it seems I did not understand where you are getting this error. I must admit I have not used or worked with that area in years. It is a part of JCB that is due a major upgrade, overall improvement. That was a beta area, and it has never been brought to stable. Ideally the plan was that it can from an existing Joomla Component setup all your boilerplate things like fields and the basic relationships. Yet there has been little insert and even less supporting programmers to help move that forward. At this time I am overloaded with moving JCB to Joomla 4, and honestly I will have to see when I get time to look at this, unless your willing to get your hands dirty and jump in to debug things... I am not sure there will be any thing I can do soon to help. Yet if your can kinda boil it down to where the issue is and by doing so save me the time... I will be willing to help. Quick side note, JCB does not work in Google Chrome, but must run in Firefox.
Author

Sure, no problem, I can use JCB as it is used by everyone, I was just curious how that section of JCB works.
I have used a similar system a few years ago in the Yii framework, which used the database schema to create the complete CRUD schema.
First, we created a model based on the database, and then used that model to create the other sections of the site, such as the list view, create, edit, and delete.

Yes, sure, if you want that part of JCB to be improved, I will try to help you.
I really appreciate the effort you have put into creating this wonderful application, from the beginning, and now for porting it to Joomla 4, thank you!

And yes, I noticed a few years ago that JCB works better on Firefox :D

Sure, no problem, I can use JCB as it is used by everyone, I was just curious how that section of JCB works. I have used a similar system a few years ago in the Yii framework, which used the database schema to create the complete CRUD schema. First, we created a model based on the database, and then used that model to create the other sections of the site, such as the list view, create, edit, and delete. Yes, sure, if you want that part of JCB to be improved, I will try to help you. I really appreciate the effort you have put into creating this wonderful application, from the beginning, and now for porting it to Joomla 4, thank you! And yes, I noticed a few years ago that JCB works better on Firefox :D
Owner

I am refactoring most of JCB into a containerized system like Joomla 4 and this area of JCB also needs refactoring.

This is where all the code lives now: https://git.vdm.dev/joomla/Component-Builder/src/branch/staging/admin/helpers/extrusion

And this is where is must move to: https://git.vdm.dev/joomla/Component-Builder/src/branch/staging/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder

This new area holds al the new refactored code of JCB, we also have a powers repository that has decouples the code from JCB for individual project use:
https://git.vdm.dev/joomla/jcb-compiler
https://git.vdm.dev/joomla/super-powers

The new super powers of JCB will take JCB into a dimension of freedom never seen before, or so I think. Getting your head around the powers area of JCB and the soon to be released super powers ideology will be very satisfying to say the least.

Bu the way this extrusion area of JCB is also using the database to build all the views and fields, but I though of adding an xml layer to it so we can more correctly get the field types and other low level (field) details to even speed it up more, then I though well if we go there, why not use the new PARSER (still only in beta) we just build for the super powers area to get even more details from the modules and controllers and other parts of the existing component to more fully transition a extension into JCB... this it the direction we are looking at.

By the way... if your want to see what I am working on you should follow the beta version of JCB... as the it the tip of the development stream, and by the way also the version JCB is being build in.

I am refactoring most of JCB into a containerized system like Joomla 4 and this area of JCB also needs refactoring. This is where all the code lives now: https://git.vdm.dev/joomla/Component-Builder/src/branch/staging/admin/helpers/extrusion And this is where is must move to: https://git.vdm.dev/joomla/Component-Builder/src/branch/staging/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder This new area holds al the new refactored code of JCB, we also have a powers repository that has decouples the code from JCB for individual project use: https://git.vdm.dev/joomla/jcb-compiler https://git.vdm.dev/joomla/super-powers The new super powers of JCB will take JCB into a dimension of freedom never seen before, or so I think. Getting your head around the powers area of JCB and the soon to be released super powers ideology will be very satisfying to say the least. Bu the way this extrusion area of JCB is also using the database to build all the views and fields, but I though of adding an xml layer to it so we can more correctly get the field types and other low level (field) details to even speed it up more, then I though well if we go there, why not use the new [PARSER](https://git.vdm.dev/joomla-beta/com-componentbuilder/src/branch/master/libraries/jcb_powers/VDM.Joomla/src/Componentbuilder/Compiler/Power/Parser.php) (still only in beta) we just build for the super powers area to get even more details from the modules and controllers and other parts of the existing component to more fully transition a extension into JCB... this it the direction we are looking at. By the way... if your want to see what I am working on you should follow the beta version of JCB... as the it the tip of the development stream, and by the way also the version JCB is being build in.
Author

I finally had time to spend trying to debug this problem.
Okay, so I found this message from the error No "CREATE TABLE.." were found, please check your sql in administrator/components/com_componentbuilder/helpers/extrusion/a_mapping.php
Here are 2 functions, getTableName(&$query) and getFields(&$query), in bouth function. the tables name and the columns name are selected only if the name is quoted using ' or ` .
My mysql code was not quoted, so I created a functiones to add quote's to the names.

protected function addQuotesToName($name) { return "'#__" . $name . "'"; }
Now in getTableName(&$query) I do one more check like this:

elseif(strpos($query, "#") !== false){
$regex = '/#
([\w-]+)(?=\s)/';
$matches = array();

if (preg_match($regex, $query, $matches)) {
// get table name
$tableName = $this->addQuotesToName($matches[1]);
}
}

And in getFields(&$query) I do a last check like this:
if (0 === strpos($row, '')) { // get field name $name = GetHelper::between($row, '', '`');
}elseif (0 === strpos($row, "'"))
{
// get field name
$name = GetHelper::between($row, "'", "'");
}else{
$regex = '/\b(\w+)\s+INT\b/';
$matches = array();

preg_match($regex, $row, $matches);
if(!empty($matches[1])){
$name = $this->addQuotesToName($matches[1]);
}
} .
But now, after all this I'm getting a new error:
Unknown column 'text' in 'where clause' \libraries\joomla\database\driver\mysqli.php:668
JROOT\administrator\components\com_componentbuilder\helpers\componentbuilder.php:2256

I thought that the problem would disappear if I put the names of the columns between ` '', but no.
The only difference obtained is with the changes made by me, and the sql dump code should not contain no quotes whatsoever

I finally had time to spend trying to debug this problem. Okay, so I found this message from the error `No "CREATE TABLE.." were found, please check your sql` in `administrator/components/com_componentbuilder/helpers/extrusion/a_mapping.php` Here are 2 functions, `getTableName(&$query)` and `getFields(&$query)`, in bouth function. the tables name and the columns name are selected only if the name is quoted using ' or ` . My mysql code was not quoted, so I created a functiones to add quote's to the names. `protected function addQuotesToName($name) { return "'#__" . $name . "'"; }` Now in `getTableName(&$query)` I do one more check like this: elseif(strpos($query, "#__") !== false){ $regex = '/#__([\w-]+)(?=\s)/'; $matches = array(); if (preg_match($regex, $query, $matches)) { // get table name $tableName = $this->addQuotesToName($matches[1]); } } And in getFields(&$query) I do a last check like this: if (0 === strpos($row, '`')) { // get field name $name = GetHelper::between($row, '`', '`'); }elseif (0 === strpos($row, "'")) { // get field name $name = GetHelper::between($row, "'", "'"); }else{ $regex = '/\b(\w+)\s+INT\b/'; $matches = array(); preg_match($regex, $row, $matches); if(!empty($matches[1])){ $name = $this->addQuotesToName($matches[1]); } } . But now, after all this I'm getting a new error: Unknown column 'text' in 'where clause' \libraries\joomla\database\driver\mysqli.php:668 JROOT\administrator\components\com_componentbuilder\helpers\componentbuilder.php:2256 I thought that the problem would disappear if I put the names of the columns between ` '', but no. The only difference obtained is with the changes made by me, and the sql dump code should not contain no quotes whatsoever
oxido changed title from Error: No "CREATE TABLE.." were found, please check your sql. to [BETA]Error: No "CREATE TABLE.." were found, please check your sql. 2024-01-23 21:12:48 +00:00
oxido changed title from [BETA]Error: No "CREATE TABLE.." were found, please check your sql. to [BETA] Error: No "CREATE TABLE.." were found, please check your sql. 2024-01-23 21:13:22 +00:00
Author

New thread is here #1032

New thread is here #1032
oxido closed this issue 2024-02-04 00:00:48 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#990
No description provided.