Skip to content

Support VECTOR columns and indexes - #38

Merged
iamcal merged 1 commit into
iamcal:masterfrom
MohannadElemary:vector-field-type
Nov 30, 2026
Merged

iamcal merged 1 commit into
iamcal:masterfrom
MohannadElemary:vector-field-type

Conversation

@MohannadElemary

Copy link
Copy Markdown
Contributor

MariaDB 11.7+ and MySQL 9 have a VECTOR(n) column type. Laravel's $table->vector('embedding', 1536) writes it, and on MariaDB ->index() adds a vector index, so both end up in schema:dump output:

`embedding` vector(1536) NOT NULL,
VECTOR KEY `documents_embedding_vectorindex` (`embedding`) `M`='6' `DISTANCE`='cosine'

The parser throws Unsupported field type: VECTOR on the column, and Unsupported field type: KEY on the index once the column type is known. Larastan reads Laravel schema dumps with this parser and skips the whole file when it throws, so models of unrelated tables end up with missing-property errors (larastan/larastan#2665).

VECTOR and VECTOR(n) now go through the same length handling as BINARY(n), so the dimensions land in length. VECTOR INDEX and VECTOR KEY are parsed like SPATIAL INDEX/SPATIAL KEY with type VECTOR, and options like M and DISTANCE stay in more. That pair is only merged at the start of a table element rather than in the lexer, so vector still works as a plain identifier, e.g. DEFAULT vector KEY on older MariaDB.

Fixes #37

MariaDB 11.7+ and MySQL 9 have a VECTOR(n) column type, and MariaDB adds
VECTOR KEY indexes on them. Laravel's $table->vector() emits the column
(and ->index() the MariaDB index), so both show up in schema dumps, and
the parser rejected the whole dump with 'Unsupported field type'.

VECTOR INDEX/KEY is only merged at the start of a table element, not in
the lexer, so `vector` keeps working as an identifier elsewhere.
@iamcal
iamcal merged commit afa07c6 into iamcal:master Nov 30, 2026
11 checks passed
@iamcal

iamcal commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Thanks!

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.

Unsupported field type: VECTOR (MariaDB 11.7+ / MySQL 9 vector columns)

2 participants