mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-07 05:25:30 +08:00
fix(db): Messages with empty bodies always showing loading spinner due to ‘’ == null
This commit is contained in:
parent
6ddca404f5
commit
9627ae9b0c
2 changed files with 27 additions and 0 deletions
|
@ -98,6 +98,9 @@ describe "Model", ->
|
||||||
modelKey: 'testCollection'
|
modelKey: 'testCollection'
|
||||||
jsonKey: 'test_collection'
|
jsonKey: 'test_collection'
|
||||||
itemClass: SubmodelItem
|
itemClass: SubmodelItem
|
||||||
|
'testJoinedData': Attributes.JoinedData
|
||||||
|
modelKey: 'testJoinedData'
|
||||||
|
jsonKey: 'test_joined_data'
|
||||||
|
|
||||||
@json =
|
@json =
|
||||||
'id': '1234'
|
'id': '1234'
|
||||||
|
@ -126,6 +129,11 @@ describe "Model", ->
|
||||||
@m.fromJSON(@json)
|
@m.fromJSON(@json)
|
||||||
expect(@m.daysOld).toBe(undefined)
|
expect(@m.daysOld).toBe(undefined)
|
||||||
|
|
||||||
|
it "should maintain empty string as empty strings", ->
|
||||||
|
expect(@m.accountId).toBe(undefined)
|
||||||
|
@m.fromJSON({account_id: ''})
|
||||||
|
expect(@m.accountId).toBe('')
|
||||||
|
|
||||||
describe "Attributes.Number", ->
|
describe "Attributes.Number", ->
|
||||||
it "should read number attributes and coerce them to numeric values", ->
|
it "should read number attributes and coerce them to numeric values", ->
|
||||||
@m.fromJSON('test_number': 4)
|
@m.fromJSON('test_number': 4)
|
||||||
|
@ -140,6 +148,17 @@ describe "Model", ->
|
||||||
@m.fromJSON('test_number': 0)
|
@m.fromJSON('test_number': 0)
|
||||||
expect(@m.testNumber).toBe(0)
|
expect(@m.testNumber).toBe(0)
|
||||||
|
|
||||||
|
describe "Attributes.JoinedData", ->
|
||||||
|
it "should read joined data attributes and coerce them to string values", ->
|
||||||
|
@m.fromJSON('test_joined_data': null)
|
||||||
|
expect(@m.testJoinedData).toBe(null)
|
||||||
|
|
||||||
|
@m.fromJSON('test_joined_data': '')
|
||||||
|
expect(@m.testJoinedData).toBe('')
|
||||||
|
|
||||||
|
@m.fromJSON('test_joined_data': 'lolz')
|
||||||
|
expect(@m.testJoinedData).toBe('lolz')
|
||||||
|
|
||||||
describe "Attributes.Collection", ->
|
describe "Attributes.Collection", ->
|
||||||
it "should parse and inflate items", ->
|
it "should parse and inflate items", ->
|
||||||
@m.fromJSON('test_collection': [{id: '123'}])
|
@m.fromJSON('test_collection': [{id: '123'}])
|
||||||
|
|
|
@ -38,6 +38,14 @@ export default class AttributeJoinedData extends Attribute {
|
||||||
this.modelTable = modelTable;
|
this.modelTable = modelTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toJSON(val) {
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
fromJSON(val) {
|
||||||
|
return (val === null || val === undefined || val === false) ? null : `${val}`;
|
||||||
|
}
|
||||||
|
|
||||||
selectSQL() {
|
selectSQL() {
|
||||||
// NullPlaceholder is necessary because if the LEFT JOIN returns nothing, it leaves the field
|
// NullPlaceholder is necessary because if the LEFT JOIN returns nothing, it leaves the field
|
||||||
// blank, and it comes through in the result row as "" rather than NULL
|
// blank, and it comes through in the result row as "" rather than NULL
|
||||||
|
|
Loading…
Reference in a new issue