Skip to content

fix(BUG-009): require explicit nullable when alterColumn changes data type#146

Merged
s2x merged 1 commit into
mainfrom
fix/issue-56-alter-column-nullable
May 30, 2026
Merged

fix(BUG-009): require explicit nullable when alterColumn changes data type#146
s2x merged 1 commit into
mainfrom
fix/issue-56-alter-column-nullable

Conversation

@s2x

@s2x s2x commented May 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes silent data constraint corruption in alterColumn(). When calling alterColumn() with newDataType but without specifying nullable, the method silently made columns NOT NULL because null was mapped to 0.

Problem

// Column score is nullable=true
$coll->alterColumn('score', newDataType: ZVec::TYPE_FLOAT);
// BUG: score is now nullable=false - silent data constraint corruption!

Solution

Throw ZVecException when newDataType is set without explicit nullable:

$coll->alterColumn('score', newDataType: ZVec::TYPE_FLOAT);
// Throws: nullable must be explicitly specified when changing data type.

// Correct usage:
$coll->alterColumn('score', newDataType: ZVec::TYPE_FLOAT, nullable: true);

Changes

  • src/ZVec.php:474-484 - Add guard clause in alterColumn()
  • tests/bug_0009.phpt - Test exception is thrown, explicit nullable works

Tests

All 136 tests pass. Closes #56.

… type

alterColumn() with newDataType but nullable=null silently made columns
NOT NULL because null was mapped to 0. Now throws ZVecException with a
clear message when newDataType is set without nullable.

Closes #56
@s2x s2x force-pushed the fix/issue-56-alter-column-nullable branch from a7b7218 to 590f10c Compare May 30, 2026 10:21
@s2x s2x merged commit 1567eec into main May 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG-009: alterColumn() nullable=null Semantically Means "Not Nullable"

1 participant