Skip to content

fix: [SQLite3] Forge::modifyColumn() messes up table #8457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 2, 2024

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Jan 26, 2024

Description
Fixes #8410

OCI8 test failure will be fixed in #8459

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Jan 26, 2024
@kenjis kenjis force-pushed the fix-sqlite3-modifyColumn branch from 6db3322 to 12b6d45 Compare January 26, 2024 04:57
@kenjis kenjis added the database Issues or pull requests that affect the database layer label Jan 26, 2024
@kenjis
Copy link
Member Author

kenjis commented Jan 29, 2024

@dgvirtual Can you test this?

@dgvirtual
Copy link
Contributor

dgvirtual commented Jan 29, 2024

@dgvirtual Can you test this?

I would like to. How do I pull the changes into the code on my machine, what should I google for to find how its done? sth like this?

@kenjis
Copy link
Member Author

kenjis commented Jan 29, 2024

@dgvirtual If you like CLI, I recommend https://cli.github.com/

gh pr checkout 8457

Of course you can get from my repository:
https://github.com/kenjis/CodeIgniter4/tree/fix-sqlite3-modifyColumn

@dgvirtual
Copy link
Contributor

dgvirtual commented Jan 29, 2024

Hi, so I rerun the routine that I applied when filing bug report #8410.

There is still one unrequested change that happens in an unreleated column, and I am not sure how bad it is; default of column with TINYINT datatype changes from integer zero to string zero:

+----------------+----------+-------------+----------+---------+-------------+
|  Field Name      | Type       | Max Length | Nullable  | Default  | Primary Key |
+----------------+----------+-------------+----------+---------+-------------+
before:
| paid                 | TINYINT  |                     | No           | 0            | No               |
after (note col Default): 
| paid                | TINYINT  |                      | No           | '0'          | No               |

Same happens if I change the type to INT or DECIMAL.

kenjis added a commit to kenjis/CodeIgniter4 that referenced this pull request Jan 30, 2024
@kenjis kenjis force-pushed the fix-sqlite3-modifyColumn branch from 576397a to 40a84c8 Compare January 30, 2024 00:30
@kenjis
Copy link
Member Author

kenjis commented Jan 30, 2024

@dgvirtual Thank you for testing.
I've fixed.

Before modifyColumn():

CREATE TABLE `db_invoices` (
	`id` INTEGER PRIMARY KEY AUTOINCREMENT,
	`user_id` INT NOT NULL,
	`month` VARCHAR NOT NULL,
	`invoice_series` VARCHAR NOT NULL,
	`total` DECIMAL NOT NULL,
	`paid` TINYINT NOT NULL DEFAULT 0,
	`paid_date` VARCHAR NULL DEFAULT NULL,
	`created_at` DATETIME NOT NULL,
	`updated_at` DATETIME NOT NULL
)

After modifyColumn():

CREATE TABLE `db_invoices` (
	`id` INTEGER NULL,
	`user_id` INT NOT NULL,
	`month` VARCHAR NOT NULL,
	`series` VARCHAR NOT NULL,
	`total` DECIMAL NOT NULL,
	`paid` TINYINT NOT NULL DEFAULT 0,
	`paid_date` VARCHAR NULL DEFAULT NULL,
	`created_at` DATETIME NOT NULL,
	`updated_at` DATETIME NOT NULL,
	CONSTRAINT `pk_db_invoices` PRIMARY KEY(`id`)
)

kenjis added a commit to kenjis/CodeIgniter4 that referenced this pull request Jan 30, 2024
@kenjis kenjis force-pushed the fix-sqlite3-modifyColumn branch from 1704a93 to cd2d74d Compare January 30, 2024 00:46
@kenjis kenjis force-pushed the fix-sqlite3-modifyColumn branch from cb397c0 to 8d30df7 Compare January 30, 2024 06:25
@kenjis kenjis requested a review from michalsn January 30, 2024 06:38
@kenjis kenjis merged commit 24ed52b into codeigniter4:develop Feb 2, 2024
@kenjis kenjis deleted the fix-sqlite3-modifyColumn branch February 2, 2024 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them database Issues or pull requests that affect the database layer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: [SQLite3] Forge class modifyColumn() method seriously messes up sqlite3 table
3 participants