Skip to content

Commit ef9f9e7

Browse files
Merge pull request #60 from matteobortolazzo/dev
1.2.1 Fix JSON content as value
2 parents 87d8c9f + cc1060b commit ef9f9e7

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 1.2.1 (2020-02-25)
2+
3+
## Bug Fix
4+
* **JSON content:** Fix issue with JSON content as a value. ([#PR59](https://github.com/matteobortolazzo/couchdb-net/pull/59))
5+
16
# 1.2.0 (2020-01-24)
27

38
## Features

LATEST_CHANGE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
## Features
2-
* **Attachments:** Adds support for attachments. ([#PR56](https://github.com/matteobortolazzo/couchdb-net/pull/56))
1+
## Bug Fix
2+
* **JSON content:** Fix issue with JSON content as a value. ([#PR59](https://github.com/matteobortolazzo/couchdb-net/pull/59))

src/CouchDB.Driver/Translators/ConstantExpressionTranslator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private void HandleConstant(object constant)
3636
_sb.Append(((bool)constant) ? "true" : "false");
3737
break;
3838
case TypeCode.String:
39-
_sb.Append($"\"{constant}\"");
39+
_sb.Append(JsonConvert.SerializeObject(constant));
4040
break;
4141
case TypeCode.DateTime:
4242
_sb.Append(JsonConvert.SerializeObject(constant));

tests/CouchDB.Driver.UnitTests/Find/Find_Selector.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,11 @@ public void Variable_Bool_ExplicitNotFalse()
110110
var json = _rebels.Where(r => r.IsJedi != false).OrderBy(r => r.IsJedi).ToString();
111111
Assert.Equal(@"{""selector"":{""isJedi"":{""$ne"":false}},""sort"":[""isJedi""]}", json);
112112
}
113+
[Fact]
114+
public void Variable_String_IsJsonEscaped()
115+
{
116+
var json = _rebels.Where(r => r.Name == @"Chewbacca (""Chewie"")").ToString();
117+
Assert.Equal(@"{""selector"":{""name"":""Chewbacca (\""Chewie\"")""}}", json);
118+
}
113119
}
114120
}

0 commit comments

Comments
 (0)