File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1319,6 +1319,10 @@ public function escape($str)
13191319 {
13201320 return ($ str === false ) ? 0 : 1 ;
13211321 }
1322+ else if (is_numeric ($ str ) && $ str < 0 )
1323+ {
1324+ return "' {$ str }' " ;
1325+ }
13221326 else if ($ str === null )
13231327 {
13241328 return 'NULL ' ;
Original file line number Diff line number Diff line change @@ -131,5 +131,19 @@ public function testStoresConnectionTimings()
131131
132132 //--------------------------------------------------------------------
133133
134+ /**
135+ * Ensures we don't have escaped - values...
136+ *
137+ * @see https://github.com/bcit-ci/CodeIgniter4/issues/606
138+ */
139+ public function testEscapeProtectsNegativeNumbers ()
140+ {
141+ $ db = new MockConnection ($ this ->options );
142+
143+ $ db ->initialize ();
144+
145+ $ this ->assertEquals ("'-100' " , $ db ->escape (-100 ));
146+ }
147+
134148
135149}
You can’t perform that action at this time.
0 commit comments