File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -209,9 +209,12 @@ private T bsonToMember(T)(auto ref T member, Bson value)
209
209
// / Generates a Bson document from a struct/class object
210
210
Bson toSchemaBson (T)(T obj)
211
211
{
212
- static if (__traits(compiles, cast (T) null ))
212
+ static if (__traits(compiles, cast (T) null ) && __traits(compiles, {
213
+ T foo = null ;
214
+ }))
213
215
{
214
- return Bson (null );
216
+ if (obj is null )
217
+ return Bson (null );
215
218
}
216
219
217
220
Bson data = Bson.emptyObject;
@@ -294,7 +297,9 @@ Bson toSchemaBson(T)(T obj)
294
297
// / Generates a struct/class object from a Bson node
295
298
T fromSchemaBson (T)(Bson bson)
296
299
{
297
- static if (__traits(compiles, cast (T) null ))
300
+ static if (__traits(compiles, cast (T) null ) && __traits(compiles, {
301
+ T foo = null ;
302
+ }))
298
303
{
299
304
if (bson.isNull)
300
305
return null ;
@@ -358,7 +363,9 @@ T fromSchemaBson(T)(Bson bson)
358
363
}
359
364
else
360
365
{
361
- mixin (" obj." ~ memberName ~ " = bsonToMember(obj." ~ memberName ~ " , bson[name]);" );
366
+ mixin (
367
+ " obj." ~ memberName ~ " = bsonToMember(obj."
368
+ ~ memberName ~ " , bson[name]);" );
362
369
}
363
370
}
364
371
}
You can’t perform that action at this time.
0 commit comments