Feature Request: Support MySQL Spatial Datatypes
Author: rubenferreira97Created Dec 3, 2021Updated Aug 6, 2026
LabelsNG_feature_request
Environment
Knex version: 0.95.12 Database + version: MySQL 8.0.27 OS: Windows
Feature discussion / request
- Explain what is your use case
Being able to use MySQL Spatial Datatypes. Want to store districts as polygons and locations as points (SRID 4326).
- Explain what kind of feature would support this
Can store geographic data.
- Give some API proposal, how the feature should work
Here is the MySQL official docs:
https://dev.mysql.com/doc/refman/8.0/en/spatial-types.html
knex.schema.createTable('table', (table) => {
table.increments('id');
table.polygon('area').srid(4326); //srid might be options?
})This pull request seems to implement some spatial datatypes, however they seem not supported on MySQL (at least polygon). https://github.com/knex/knex/pull/4776
Source: knex/knex