我正在更新postgres数据库中的字段,我需要将此字段设置为空,这对于这类字段是默认的NULL。
这是查询,我尝试设置为null的字段是link_target_language
import { put, call } from 'redux-saga/effects';
// success route
const arg = fetchMessage(channel);
let gen = onFetchMessage(arg);
assert.deepEqual(
gen.next().value,
put(requestMessages()),
'should ...'
);
assert.deepEqual(
gen.next().value,
call(fetch, 'api/messages/' + arg.payload),
'should ...'
);
assert.deepEqual(
gen.next({ ok: true, json: () => 'test data' }).value,
'test data',
'should ...'
);
assert.deepEqual(
gen.next('test res').value,
put(receiveMessage('test res', arg.payload, moment().format('lll')), // you may need to get date from args, if date does not match
'should ...'
);
assert.deepEqual(
gen.next().done,
true,
'should ...'
);
// unsuccessful route
const arg = fetchMessage(channel);
let gen = onFetchMessage(arg);
gen.next();
gen.next();
assert.deepEqual(
gen.next({ ok: false, json: () => 'test data' }).done,
true,
'should ...'
);
// exception route
const arg = fetchMessage(channel);
let gen = onFetchMessage(arg);
gen.next();
gen.next();
assert.deepEqual(
gen.throw('some error').value,
put(rejectMessage('some error'),
'should ...'
);
null此处不起作用,因为任何数组字段都需要{}:
UPDATE links SET link_target_language = null WHERE unique_id = 'b06457b8'
但是如果我放置{}那么db中的字段{}不是NULL而不是真空字段。
那么如何使用js从UPDATE命令真正清空postgress中的数组字段?
答案 0 :(得分:0)
将null
投射到数组类型:
set link_target_language = null::text[]