Skip to content

Commit

Permalink
Merge pull request #48 from seandenigris/bug_unknown-field-error
Browse files Browse the repository at this point in the history
[Bug]: Magritte - Unknown Field Read Error
  • Loading branch information
seandenigris authored Jan 31, 2024
2 parents fcffa0b + 47e572f commit bbe8f5f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
20 changes: 17 additions & 3 deletions repository/Neo-CSV-Magritte/MACSVWriter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Class {
'subjects',
'map',
'subjectDescription',
'ignoresUnkownFields'
'ignoresUnkownFields',
'includesHeader'
],
#category : #'Neo-CSV-Magritte-Visitors'
}
Expand Down Expand Up @@ -85,6 +86,14 @@ MACSVWriter >> map: aString fieldDo: aBlock [
self map add: field.
]

{ #category : #accessing }
MACSVWriter >> map: aString fieldSource: aBlock [

self
map: aString
fieldDo: [ :field | field descriptionSource: aBlock ]
]

{ #category : #accessing }
MACSVWriter >> subjectDescription [
^ subjectDescription ifNil: [ subjectDescription := self subjects first magritteDescription ]
Expand Down Expand Up @@ -128,10 +137,15 @@ MACSVWriter >> writeToStream: aStream [
| converter wrappedConverter |
converter := field
propertyAt: self fieldWriterPropertyKey
ifAbsent: [ [ :anObject | field read: anObject ] ].
ifAbsent: #yourself.
wrappedConverter := [ :anObject |
(self ignoresUnknownFields not or: [ field accessor canRead: anObject ])
ifTrue: [ converter value: anObject ]
ifTrue: [
| aValue |
aValue := field read: anObject.
aValue = field undefinedValue ifTrue: [
aValue := field default ].
converter cull: aValue cull: anObject ]
ifFalse: [ nil ] ].
self writer addField: wrappedConverter ].

Expand Down
1 change: 0 additions & 1 deletion repository/Neo-CSV-Magritte/MACSVWriterTests.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ MACSVWriterTests >> testAddedDescription [
MAUrlDescription new
accessor: #wikipediaUrl;
priority: 25;
csvFieldName: 'Wikipedia';
yourself ] ];
execute.

Expand Down

0 comments on commit bbe8f5f

Please sign in to comment.