Release of v3.2.2-alpha4

Update the Schema class to also update null mismatching if needed.
This commit is contained in:
Robot 2024-06-07 23:03:20 +02:00
parent b67e534b9f
commit 894d691897
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
11 changed files with 156 additions and 37 deletions

View File

@ -1,11 +1,12 @@
# v3.2.2-alpha3 # v3.2.2-alpha4
- Fix permission issue for admin views. - Update the Schema class to also update null mismatching if needed
- Add extending options to interfaces.
# v3.2.2-alpha # v3.2.2-alpha
- Fix auto build from SQL in Joomla 4 and 5. - Fix auto build from SQL in Joomla 4 and 5.
- Fix permission issue for admin views.
- Add extending options to interfaces.
# v3.2.1 # v3.2.1

View File

@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have! Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.2.2-alpha3) with **ALL** its features and **ALL** concepts totally open-source and free! You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.2.2-alpha4) with **ALL** its features and **ALL** concepts totally open-source and free!
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45) > Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
@ -144,13 +144,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 5th June, 2024 + *Last Build*: 7th June, 2024
+ *Version*: 3.2.2-alpha3 + *Version*: 3.2.2-alpha4
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **764972** + *Line count*: **765384**
+ *Field count*: **2100** + *Field count*: **2100**
+ *File count*: **5299** + *File count*: **5304**
+ *Folder count*: **471** + *Folder count*: **471**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com). > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).

View File

@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have! Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.2.2-alpha3) with **ALL** its features and **ALL** concepts totally open-source and free! You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.2.2-alpha4) with **ALL** its features and **ALL** concepts totally open-source and free!
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45) > Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
@ -144,13 +144,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 5th June, 2024 + *Last Build*: 7th June, 2024
+ *Version*: 3.2.2-alpha3 + *Version*: 3.2.2-alpha4
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **764972** + *Line count*: **765384**
+ *Field count*: **2100** + *Field count*: **2100**
+ *File count*: **5299** + *File count*: **5304**
+ *Folder count*: **471** + *Folder count*: **471**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com). > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).

View File

@ -364,9 +364,9 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_power` (
`approved_paths` TEXT NULL, `approved_paths` TEXT NULL,
`composer` TEXT NULL, `composer` TEXT NULL,
`description` TEXT NULL, `description` TEXT NULL,
`extends` VARCHAR(36) NOT NULL DEFAULT '', `extends` VARCHAR(36) NULL DEFAULT '',
`extends_custom` VARCHAR(64) NULL DEFAULT '', `extends_custom` VARCHAR(64) NULL DEFAULT '',
`extendsinterfaces` TEXT NOT NULL, `extendsinterfaces` TEXT NULL,
`extendsinterfaces_custom` TEXT NULL, `extendsinterfaces_custom` TEXT NULL,
`guid` VARCHAR(36) NOT NULL DEFAULT '', `guid` VARCHAR(36) NOT NULL DEFAULT '',
`head` TEXT NULL, `head` TEXT NULL,

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.10" method="upgrade"> <extension type="component" version="3.10" method="upgrade">
<name>COM_COMPONENTBUILDER</name> <name>COM_COMPONENTBUILDER</name>
<creationDate>5th June, 2024</creationDate> <creationDate>7th June, 2024</creationDate>
<author>Llewellyn van der Merwe</author> <author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail> <authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>https://dev.vdm.io</authorUrl> <authorUrl>https://dev.vdm.io</authorUrl>
<copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright> <copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license> <license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<version>3.2.2-alpha3</version> <version>3.2.2-alpha4</version>
<description><![CDATA[ <description><![CDATA[
<h1>Component Builder (v.3.2.2-alpha3)</h1> <h1>Component Builder (v.3.2.2-alpha4)</h1>
<div style="clear: both;"></div> <div style="clear: both;"></div>
<p>The Component Builder for [Joomla](https://extensions.joomla.org/extension/component-builder/) is highly advanced tool that is truly able to build extremely complex components in a fraction of the time. <p>The Component Builder for [Joomla](https://extensions.joomla.org/extension/component-builder/) is highly advanced tool that is truly able to build extremely complex components in a fraction of the time.

View File

@ -151,7 +151,7 @@
<version>3.2.2-alpha</version> <version>3.2.2-alpha</version>
<infourl title="Component Builder!">https://dev.vdm.io</infourl> <infourl title="Component Builder!">https://dev.vdm.io</infourl>
<downloads> <downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.2-alpha3.zip</downloadurl> <downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.2-alpha4.zip</downloadurl>
</downloads> </downloads>
<tags> <tags>
<tag>alpha</tag> <tag>alpha</tag>
@ -166,10 +166,10 @@
<element>pkg_component_builder</element> <element>pkg_component_builder</element>
<type>package</type> <type>package</type>
<client>site</client> <client>site</client>
<version>3.2.2-alpha3</version> <version>3.2.2-alpha4</version>
<infourl title="Component Builder!">https://dev.vdm.io</infourl> <infourl title="Component Builder!">https://dev.vdm.io</infourl>
<downloads> <downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.2-alpha3.zip</downloadurl> <downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.2-alpha4.zip</downloadurl>
</downloads> </downloads>
<tags> <tags>
<tag>alpha</tag> <tag>alpha</tag>

View File

@ -343,9 +343,17 @@ abstract class Schema implements SchemaInterface
'expected' => $expected['type'] 'expected' => $expected['type']
]; ];
} }
// check if update of default values is needed // check if update of default values is needed
if ($this->checkDefault($table, $column) && !isset($requireUpdate[$column])) elseif ($this->checkDefault($table, $column))
{
$requireUpdate[$column] = [
'column' => $column,
'current' => $current->Type,
'expected' => $expected['type']
];
}
// check if update of null is needed
elseif ($this->checkNull($table, $column))
{ {
$requireUpdate[$column] = [ $requireUpdate[$column] = [
'column' => $column, 'column' => $column,
@ -391,13 +399,21 @@ abstract class Schema implements SchemaInterface
$default = $this->getDefaultValue($type, $db_default); $default = $this->getDefaultValue($type, $db_default);
// Prepare the null switch, and auto increment statement // Prepare the null switch, and auto increment statement
$null_switch = !empty($db['null_switch']) ? " " . $db['null_switch'] : ''; $null_switch = !empty($db['null_switch']) ? ' ' . $db['null_switch'] : '';
// Prepare the auto increment statement
$auto_increment = !empty($db['auto_increment']) ? " AUTO_INCREMENT" : ''; $auto_increment = !empty($db['auto_increment']) ? " AUTO_INCREMENT" : '';
// If there's a default value, the column should not be nullable
if ($default !== '')
{
$null_switch = '';
}
$this->setKeys($db); $this->setKeys($db);
// Assemble the SQL snippet for the column definition // Assemble the SQL snippet for the column definition
return "{$column_name} {$type}{$null_switch}{$default}{$auto_increment}"; return "{$column_name} {$type}{$null_switch}{$auto_increment}{$default}";
} catch (\Exception $e) { } catch (\Exception $e) {
throw new \Exception("Error: failed to generate column definition for ($table.$field). " . $e->getMessage()); throw new \Exception("Error: failed to generate column definition for ($table.$field). " . $e->getMessage());
} }
@ -448,6 +464,61 @@ abstract class Schema implements SchemaInterface
return false; return false;
} }
/**
* Check and Update the null value if needed, including existing data adjustments
*
* @param string $table The table to update.
* @param string $column The column/field to check.
*
* @return bool
* @since 3.2.2
*/
protected function checkNull(string $table, string $column): bool
{
// Retrieve the expected column configuration
$expected = $this->table->get($table, $column, 'db');
// Skip updates if the null_switch is not set
if (!isset($expected['null_switch']))
{
return false;
}
// Retrieve the current column configuration
$current = $this->columns[$column];
// Skip updates if the Null is not set
if (!isset($current->Null))
{
return false;
}
// set the expected NULL
$expected_null = 'NO';
if ($expected['null_switch'] === "NULL")
{
$expected_null = 'YES';
}
// set the current NULL
$current_null = $current->Null;
// Prepare the type and default value SQL statement
$type = $expected['type'] ?? 'TEXT';
$db_default = isset($expected['default']) ? $expected['default'] : null;
$default = $this->getDefaultValue($type, $db_default, true);
// check the null values if they match
if ($current_null !== $expected_null && $current_null === 'NO' && empty($default))
{
$this->success[] = "Success: updated the ($column) null state in $table table.";
return true;
}
return false;
}
/** /**
* Update the data type of the given fields. * Update the data type of the given fields.
* *
@ -679,8 +750,8 @@ abstract class Schema implements SchemaInterface
* Adjusts the default value SQL fragment for a database field based on its type and specific rules. * Adjusts the default value SQL fragment for a database field based on its type and specific rules.
* *
* If the field is of type DATETIME and the Joomla version is not 3, it sets the default to CURRENT_TIMESTAMP * If the field is of type DATETIME and the Joomla version is not 3, it sets the default to CURRENT_TIMESTAMP
* if not explicitly specified otherwise. For all other types, or when a 'EMPTY' default is specified, it handles * if not explicitly specified otherwise. For all other types it handles defaults by either leaving them unset or applying
* defaults by either leaving them unset or applying the provided default, properly quoted for SQL safety. * the provided default, properly quoted for SQL safety. When a 'EMPTY' default is specified, it returns no default at all. (:)
* *
* @param string $type The type of the database field (e.g., 'DATETIME'). * @param string $type The type of the database field (e.g., 'DATETIME').
* @param string|null $defaultValue Optional default value for the field, null if not provided. * @param string|null $defaultValue Optional default value for the field, null if not provided.
@ -691,7 +762,7 @@ abstract class Schema implements SchemaInterface
*/ */
protected function getDefaultValue(string $type, ?string $defaultValue, bool $pure = false): string protected function getDefaultValue(string $type, ?string $defaultValue, bool $pure = false): string
{ {
if ($defaultValue === null) if ($defaultValue === null || strtoupper($defaultValue) === 'EMPTY')
{ {
return ''; return '';
} }
@ -722,11 +793,7 @@ abstract class Schema implements SchemaInterface
return 'NULL'; return 'NULL';
} }
if (is_string($value) && strtoupper($value) === 'EMPTY') if (is_numeric($value))
{
return "''";
}
elseif (is_numeric($value))
{ {
if (filter_var($value, FILTER_VALIDATE_INT)) if (filter_var($value, FILTER_VALIDATE_INT))
{ {

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Builder;
use VDM\Joomla\Abstraction\Registry\Traits\IsArray;
use VDM\Joomla\Interfaces\Registryinterface;
use VDM\Joomla\Abstraction\Registry;
/**
* Languages Builder Class
*
* @since 3.2.2
*/
final class Languages extends Registry implements Registryinterface
{
/**
* Is an Array
*
* @since 3.2.2
*/
use IsArray;
}

View File

@ -14,6 +14,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service;
use Joomla\DI\Container; use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface; use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Languages;
use VDM\Joomla\Componentbuilder\Compiler\Builder\LanguageMessages; use VDM\Joomla\Componentbuilder\Compiler\Builder\LanguageMessages;
use VDM\Joomla\Componentbuilder\Compiler\Builder\Layout; use VDM\Joomla\Componentbuilder\Compiler\Builder\Layout;
use VDM\Joomla\Componentbuilder\Compiler\Builder\LayoutData; use VDM\Joomla\Componentbuilder\Compiler\Builder\LayoutData;
@ -86,6 +87,9 @@ class BuilderLZ implements ServiceProviderInterface
*/ */
public function register(Container $container) public function register(Container $container)
{ {
$container->alias(Languages::class, 'Compiler.Builder.Languages')
->share('Compiler.Builder.Languages', [$this, 'getLanguages'], true);
$container->alias(LanguageMessages::class, 'Compiler.Builder.Language.Messages') $container->alias(LanguageMessages::class, 'Compiler.Builder.Language.Messages')
->share('Compiler.Builder.Language.Messages', [$this, 'getLanguageMessages'], true); ->share('Compiler.Builder.Language.Messages', [$this, 'getLanguageMessages'], true);
@ -246,6 +250,19 @@ class BuilderLZ implements ServiceProviderInterface
->share('Compiler.Builder.Views.Default.Ordering', [$this, 'getViewsDefaultOrdering'], true); ->share('Compiler.Builder.Views.Default.Ordering', [$this, 'getViewsDefaultOrdering'], true);
} }
/**
* Get The Languages Class.
*
* @param Container $container The DI container.
*
* @return Languages
* @since 3.2.0
*/
public function getLanguages(Container $container): Languages
{
return new Languages();
}
/** /**
* Get The LanguageMessages Class. * Get The LanguageMessages Class.
* *

View File

@ -3262,7 +3262,7 @@ class Table extends BaseTable implements Tableinterface
'db' => [ 'db' => [
'type' => 'VARCHAR(36)', 'type' => 'VARCHAR(36)',
'default' => '', 'default' => '',
'null_switch' => 'NOT NULL', 'null_switch' => 'NULL',
'unique_key' => false, 'unique_key' => false,
'key' => false, 'key' => false,
], ],
@ -3342,7 +3342,7 @@ class Table extends BaseTable implements Tableinterface
'db' => [ 'db' => [
'type' => 'TEXT', 'type' => 'TEXT',
'default' => 'EMPTY', 'default' => 'EMPTY',
'null_switch' => 'NOT NULL', 'null_switch' => 'NULL',
'unique_key' => false, 'unique_key' => false,
'key' => false, 'key' => false,
], ],

View File

@ -9810,7 +9810,7 @@ class Com_ComponentbuilderInstallerScript
echo '<div style="background-color: #fff;" class="alert alert-info"><a target="_blank" href="https://dev.vdm.io" title="Component Builder"> echo '<div style="background-color: #fff;" class="alert alert-info"><a target="_blank" href="https://dev.vdm.io" title="Component Builder">
<img src="components/com_componentbuilder/assets/images/vdm-component.jpg"/> <img src="components/com_componentbuilder/assets/images/vdm-component.jpg"/>
</a> </a>
<h3>Upgrade to Version 3.2.2-alpha3 Was Successful! Let us know if anything is not working as expected.</h3></div>'; <h3>Upgrade to Version 3.2.2-alpha4 Was Successful! Let us know if anything is not working as expected.</h3></div>';
// Set db if not set already. // Set db if not set already.
if (!isset($db)) if (!isset($db))