fix: Long search term causes server error writing query to db (#2237)
closes #2234
This commit is contained in:
parent
5f3a38bf87
commit
1a2a0f4264
|
@ -984,6 +984,21 @@ describe("#documents.search", () => {
|
||||||
expect(body.data.length).toEqual(0);
|
expect(body.data.length).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not error when search term is very long", async () => {
|
||||||
|
const { user } = await seed();
|
||||||
|
const res = await server.post("/api/documents.search", {
|
||||||
|
body: {
|
||||||
|
token: user.getJwtToken(),
|
||||||
|
query:
|
||||||
|
"much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much much longer search term",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const body = await res.json();
|
||||||
|
|
||||||
|
expect(res.status).toEqual(200);
|
||||||
|
expect(body.data.length).toEqual(0);
|
||||||
|
});
|
||||||
|
|
||||||
it("should return draft documents created by user if chosen", async () => {
|
it("should return draft documents created by user if chosen", async () => {
|
||||||
const { user } = await seed();
|
const { user } = await seed();
|
||||||
const document = await buildDocument({
|
const document = await buildDocument({
|
||||||
|
|
|
@ -15,6 +15,9 @@ const SearchQuery = sequelize.define(
|
||||||
},
|
},
|
||||||
query: {
|
query: {
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
|
set(val) {
|
||||||
|
this.setDataValue("query", val.substring(0, 255));
|
||||||
|
},
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
},
|
},
|
||||||
results: {
|
results: {
|
||||||
|
|
Reference in New Issue