Skip to content
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

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

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 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
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 kenjis merged commit 24ed52b into codeigniter4:develop Feb 2, 2024
62 checks passed
@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