mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Fix data type inconsistencies in directus_shares table (#10740)
* Fix date resolution in share info endpoint * Add note on leaving fields blank * Tweak example to use proper db client * Treat mysql 0000-00-00 00:00:00 as null * Fix migration for mysql 5 * Add missing defaults to system fields
This commit is contained in:
@@ -139,7 +139,7 @@ router.get(
|
||||
_or: [
|
||||
{
|
||||
date_start: {
|
||||
_lte: '$NOW',
|
||||
_lte: new Date().toISOString(),
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -153,7 +153,7 @@ router.get(
|
||||
_or: [
|
||||
{
|
||||
date_end: {
|
||||
_gte: '$NOW',
|
||||
_gte: new Date().toISOString(),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -10,8 +10,11 @@ export async function up(knex: Knex): Promise<void> {
|
||||
table.string('password');
|
||||
table.uuid('user_created').references('id').inTable('directus_users').onDelete('SET NULL');
|
||||
table.timestamp('date_created').defaultTo(knex.fn.now());
|
||||
table.timestamp('date_start');
|
||||
table.timestamp('date_end');
|
||||
|
||||
// This was changed after the migration went live to retroactively fix mysql5, see #10693
|
||||
table.timestamp('date_start').nullable().defaultTo(null);
|
||||
table.timestamp('date_end').nullable().defaultTo(null);
|
||||
|
||||
table.integer('times_used').defaultTo(0);
|
||||
table.integer('max_uses');
|
||||
});
|
||||
|
||||
@@ -12,3 +12,5 @@ width: full
|
||||
group: null
|
||||
translations: null
|
||||
note: null
|
||||
conditions: null
|
||||
required: false
|
||||
|
||||
@@ -32,15 +32,19 @@ fields:
|
||||
iconRight: lock
|
||||
masked: true
|
||||
width: half
|
||||
note: $t:shared_leave_blank_for_unlimited
|
||||
|
||||
- field: date_start
|
||||
width: half
|
||||
note: $t:shared_leave_blank_for_unlimited
|
||||
|
||||
- field: date_end
|
||||
width: half
|
||||
note: $t:shared_leave_blank_for_unlimited
|
||||
|
||||
- field: max_uses
|
||||
width: half
|
||||
note: $t:shared_leave_blank_for_unlimited
|
||||
|
||||
- field: times_used
|
||||
width: half
|
||||
|
||||
@@ -14,7 +14,7 @@ export default function getDefaultValue(
|
||||
if (defaultValue === 'null') return null;
|
||||
if (defaultValue === 'NULL') return null;
|
||||
|
||||
// Check if the default is wrapped in an extra pair of quotes, this happens in SQLite
|
||||
// Check if the default is wrapped in an extra pair of quotes, this happens in SQLite / MariaDB
|
||||
if (
|
||||
typeof defaultValue === 'string' &&
|
||||
((defaultValue.startsWith(`'`) && defaultValue.endsWith(`'`)) ||
|
||||
@@ -23,6 +23,8 @@ export default function getDefaultValue(
|
||||
defaultValue = defaultValue.slice(1, -1);
|
||||
}
|
||||
|
||||
if (defaultValue === '0000-00-00 00:00:00') return null;
|
||||
|
||||
switch (type) {
|
||||
case 'bigInteger':
|
||||
case 'integer':
|
||||
|
||||
Reference in New Issue
Block a user