From 3a07b2297b655f80c30d34f7626ad833360c300a Mon Sep 17 00:00:00 2001 From: Piotr Tomasik Date: Thu, 11 Jul 2013 16:06:45 -0700 Subject: [PATCH 1/2] Warn user about doom and gloom surrounding custom typecasting --- Readme.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Readme.md b/Readme.md index 78291ab8f..45165b092 100644 --- a/Readme.md +++ b/Readme.md @@ -850,6 +850,20 @@ connection.query({ } }); ``` +WARNING: YOU MUST INVOKE the parser before returning from a custom typeCast function. +``` +field.string() +field.buffer() +field.geometry() +``` +are aliases for +``` +parser.parseLengthCodedString() +parser.parseLengthCodedBuffer() +parser.parseGeometryValue() +``` +You can find which field function you need to use by looking at: [RowDataPacket.prototype._typeCast](https://github.com/felixge/node-mysql/blob/master/lib/protocol/packets/RowDataPacket.js#L41) + If you need a buffer there's also a `.buffer()` function and also a `.geometry()` one both used by the default type cast that you can use. From e76dc97e8710507d4fa26fe47db9cddfa942c3de Mon Sep 17 00:00:00 2001 From: Piotr Tomasik Date: Thu, 11 Jul 2013 16:42:54 -0700 Subject: [PATCH 2/2] Update Readme.md --- Readme.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Readme.md b/Readme.md index 45165b092..c415bf1e3 100644 --- a/Readme.md +++ b/Readme.md @@ -850,7 +850,8 @@ connection.query({ } }); ``` -WARNING: YOU MUST INVOKE the parser before returning from a custom typeCast function. +__WARNING: YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once.( see #539 for discussion)__ + ``` field.string() field.buffer() @@ -862,11 +863,8 @@ parser.parseLengthCodedString() parser.parseLengthCodedBuffer() parser.parseGeometryValue() ``` -You can find which field function you need to use by looking at: [RowDataPacket.prototype._typeCast](https://github.com/felixge/node-mysql/blob/master/lib/protocol/packets/RowDataPacket.js#L41) - +__You can find which field function you need to use by looking at: [RowDataPacket.prototype._typeCast](https://github.com/felixge/node-mysql/blob/master/lib/protocol/packets/RowDataPacket.js#L41)__ -If you need a buffer there's also a `.buffer()` function and also a `.geometry()` one -both used by the default type cast that you can use. ## Connection Flags