? ? Pending

User tests: Successful: Unsuccessful:

avatar richard67
richard67
2 Jun 2020

Pull Request for Issue # .

Summary of Changes

Allow to use "varchar" as synonym for "character varying" in update SQL scripts for PostgreSQL like it is already used in the installation SQL scripts.

Currently we use "varchar" as data type in our installation SQL scripts for PostgreSQL, which is a synonym for "character varying".

But in the update SQL scripts for PostgreSQL we have to use "character varying", otherwise the database checker (System - Information - Database) detects (false) errors which can't be fixed.

The reason is that in the information schema this data type is saved as "character varying".

This has been a source of mistakes in past many times and has required critical fixes on old update SQL scripts for production releases even, because contributors creating new database tables except that they can use the same SQL as in the installation script, but that's not the case.

This Pull Request (PR) here fixes that by allowing both synonyms in update SQL scripts (but of course still querying the information schema for "character varying" in both cases).

This makes it possible to use the same SQL for creating tables in the installation and the update SQL scripts for PostgreSQL and so increase pretty much maintainability of the update scripts. Less secret knowledge needed for that with this PR.

Testing Instructions

Requirements

The test requires an installation of a current 4.0-dev branch or a latest nightly build or a 4.0 Beta 1 using a PostgreSQL database.

There is no need to make a new installation, you can use an existing one.

Testing Procedure

  1. In backend, go to "System - Information - Database" and verify that there are no database errors shown for the CMS.

  2. Find some update SQL script for PostgreSQL which contains some "CREATE TABLE" or "ALTER TABLE" statement containing a column with data type "character varying", and change this to "varchar" (Important: Type names always lowercase for PostgreSQL!!!).
    For example in file https://github.com/joomla/joomla-cms/blob/4.0-dev/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-05-21.sql#L5 , change

ALTER TABLE "#__history" ALTER COLUMN "item_id" TYPE character varying(50);

to

ALTER TABLE "#__history" ALTER COLUMN "item_id" TYPE varchar(50);
  1. Go to "System - Information - Database" or refresh the page if still there.

Result: There is one problem shown for the CMS.

  1. Move the mouse over the badge for the problem.

Result: A popup shows details. There is one error shown for the column which has been modified in step 2 in the update SQL script.
no-patch-error-varchar

  1. Select the check box for the row with the CMS error and use the "Update Structure" button.

Result: No change, the error can't be fixed.

  1. Apply the patch of this PR.

  2. Go again to "System - Information - Database" or refresh the page if still there.

Result: No database problem found, all ok.

  1. Using a tool like e.g. phpPgAdmin, modify the definition of the column which has been modified in step 2 in the update SQL script, e.g. change the length to a smaller value:
    phppgadmin-change-column-length

  2. Go again to "System - Information - Database" or refresh the page if still there.

Result: One database problem found, the details in the popup show it is related to the type of the previously modified column.

  1. Select the check box for the row with the CMS error and use the "Update Structure" button.

Result: No database problem found, all ok.

Expected result

Like in the installation SQL scripts for PostgreSQL it is possible to use "varchar" as synonym for "character varying" in the update SQL scripts for that database type.

No false database errors which can't be fixed are detected by the database schema checker when using "varchar" as data type for a column.

Real database errors for such columns are detected and can be fixed by using the "Update Structure" button.

Actual result

When using "varchar" as synonym for "character varying" in the update SQL scripts for PostgreSQL like it is used in the installation SQL scripts for that database type, a false error is detected by the database schema checker, and the error can't be fixed by using the "Update Structure" button.

Documentation Changes Required

None.

avatar richard67 richard67 - open - 2 Jun 2020
avatar richard67 richard67 - change - 2 Jun 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 2 Jun 2020
Category Libraries
avatar richard67 richard67 - change - 2 Jun 2020
The description was changed
avatar richard67 richard67 - edited - 2 Jun 2020
avatar richard67 richard67 - change - 2 Jun 2020
The description was changed
avatar richard67 richard67 - edited - 2 Jun 2020
avatar richard67 richard67 - change - 2 Jun 2020
The description was changed
avatar richard67 richard67 - edited - 2 Jun 2020
avatar richard67
richard67 - comment - 2 Jun 2020

@alikon And another one, this time for PostgreSQL only. Could you test this, too? Thanks in advance.

avatar richard67 richard67 - change - 2 Jun 2020
The description was changed
avatar richard67 richard67 - edited - 2 Jun 2020
avatar alikon alikon - test_item - 7 Jun 2020 - Tested successfully
avatar alikon
alikon - comment - 7 Jun 2020

I have tested this item successfully on 96f53d9


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29380.

avatar richard67
richard67 - comment - 7 Jun 2020

@twister65 As far as I remember you have PostgreSQL, too. Could you test this PR here? Is an easy test and a nice to have for J4 on PostgreSQL. Thanks in advance.

avatar twister65 twister65 - test_item - 7 Jun 2020 - Tested successfully
avatar twister65
twister65 - comment - 7 Jun 2020

I have tested this item successfully on 96f53d9


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29380.

avatar Quy Quy - change - 7 Jun 2020
Status Pending Ready to Commit
avatar Quy
Quy - comment - 7 Jun 2020

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29380.

avatar richard67 richard67 - change - 7 Jun 2020
Labels Added: ? ?
avatar richard67
richard67 - comment - 7 Jun 2020

Thanks guys for testing.

avatar wilsonge wilsonge - change - 8 Jun 2020
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-06-08 12:07:09
Closed_By wilsonge
Labels
avatar wilsonge wilsonge - close - 8 Jun 2020
avatar wilsonge wilsonge - merge - 8 Jun 2020
avatar wilsonge
wilsonge - comment - 8 Jun 2020

Nice one! thankyou!

Add a Comment

Login with GitHub to post a comment