| | @@ -726,13 +726,10 @@ |
| 726 | 726 | cson_value * objV = NULL; |
| 727 | 727 | cson_object * obj = NULL; |
| 728 | 728 | assert( (code>FSL_JSON_W_START) |
| 729 | 729 | && (code<FSL_JSON_W_END) |
| 730 | 730 | && "Invalid warning code."); |
| 731 | | - if( BITSET_GET(g.json.warnings.bitset,code) ){ |
| 732 | | - return; |
| 733 | | - } |
| 734 | 731 | if(!g.json.warnings.v){ |
| 735 | 732 | g.json.warnings.v = cson_value_new_array(); |
| 736 | 733 | assert((NULL != g.json.warnings.v) && "Alloc error."); |
| 737 | 734 | g.json.warnings.a = cson_value_get_array(g.json.warnings.v); |
| 738 | 735 | json_gc_add("$WARNINGS",g.json.warnings.v,0); |
| | @@ -746,11 +743,10 @@ |
| 746 | 743 | /* FIXME: treat NULL msg as standard warning message for |
| 747 | 744 | the code, but we don't have those yet. |
| 748 | 745 | */ |
| 749 | 746 | cson_object_set(obj,"text",cson_value_new_string(msg,strlen(msg))); |
| 750 | 747 | } |
| 751 | | - BITSET_SET(g.json.warnings.bitset,code); |
| 752 | 748 | } |
| 753 | 749 | |
| 754 | 750 | /* |
| 755 | 751 | ** Splits zStr (which must not be NULL) into tokens separated by the |
| 756 | 752 | ** given separator character. If doDeHttp is true then each element |
| | @@ -1305,24 +1301,27 @@ |
| 1305 | 1301 | ** object and this function will return pTgt. If pTgt is NULL then a |
| 1306 | 1302 | ** new Array object is created and returned (owned by the |
| 1307 | 1303 | ** caller). Each row of pStmt is converted to an Object and appended |
| 1308 | 1304 | ** to the array. |
| 1309 | 1305 | */ |
| 1310 | | -static cson_value * json_stmt_to_array_of_obj(Stmt *pStmt, |
| 1311 | | - cson_value * pTgt){ |
| 1306 | +cson_value * json_stmt_to_array_of_obj(Stmt *pStmt, |
| 1307 | + cson_value * pTgt){ |
| 1312 | 1308 | cson_value * v = pTgt ? pTgt : cson_value_new_array(); |
| 1313 | 1309 | cson_array * a = cson_value_get_array(pTgt ? pTgt : v); |
| 1310 | + char const * warnMsg = NULL; |
| 1314 | 1311 | assert( NULL != a ); |
| 1315 | 1312 | while( (SQLITE_ROW==db_step(pStmt)) ){ |
| 1316 | 1313 | cson_value * row = cson_sqlite3_row_to_object(pStmt->pStmt); |
| 1317 | | - if(!row){ |
| 1318 | | - json_warn( FSL_JSON_W_ROW_TO_JSON_FAILED, |
| 1319 | | - "Could not convert at least one result row to JSON." ); |
| 1314 | + if(!row && !warnMsg){ |
| 1315 | + warnMsg = "Could not convert at least one result row to JSON."; |
| 1320 | 1316 | continue; |
| 1321 | 1317 | } |
| 1322 | 1318 | cson_array_append(a, row); |
| 1323 | 1319 | } |
| 1320 | + if(warnMsg){ |
| 1321 | + json_warn( FSL_JSON_W_ROW_TO_JSON_FAILED, warnMsg ); |
| 1322 | + } |
| 1324 | 1323 | return v; |
| 1325 | 1324 | } |
| 1326 | 1325 | |
| 1327 | 1326 | /* |
| 1328 | 1327 | ** /json/version implementation. |
| | @@ -1606,10 +1605,11 @@ |
| 1606 | 1605 | cson_object * pay; |
| 1607 | 1606 | cson_value * listV; |
| 1608 | 1607 | cson_array * list; |
| 1609 | 1608 | char const * range = NULL; |
| 1610 | 1609 | int which = 0; |
| 1610 | + char * sawConversionError = NULL; |
| 1611 | 1611 | Stmt q; |
| 1612 | 1612 | if( !g.perm.Read ){ |
| 1613 | 1613 | g.json.resultCode = FSL_JSON_E_DENIED; |
| 1614 | 1614 | return NULL; |
| 1615 | 1615 | } |
| | @@ -1670,17 +1670,19 @@ |
| 1670 | 1670 | cson_object_set(pay,"branches",listV); |
| 1671 | 1671 | while((SQLITE_ROW==db_step(&q))){ |
| 1672 | 1672 | cson_value * v = cson_sqlite3_column_to_value(q.pStmt,0); |
| 1673 | 1673 | if(v){ |
| 1674 | 1674 | cson_array_append(list,v); |
| 1675 | | - }else{ |
| 1676 | | - char * msg = mprintf("Column-to-json failed @ %s:%d", |
| 1677 | | - __FILE__,__LINE__); |
| 1678 | | - json_warn(FSL_JSON_W_COL_TO_JSON_FAILED,msg); |
| 1679 | | - free(msg); |
| 1675 | + }else if(!sawConversionError){ |
| 1676 | + sawConversionError = mprintf("Column-to-json failed @ %s:%d", |
| 1677 | + __FILE__,__LINE__); |
| 1680 | 1678 | } |
| 1681 | 1679 | } |
| 1680 | + if( sawConversionError ){ |
| 1681 | + json_warn(FSL_JSON_W_COL_TO_JSON_FAILED,sawConversionError); |
| 1682 | + free(sawConversionError); |
| 1683 | +} |
| 1682 | 1684 | return payV; |
| 1683 | 1685 | } |
| 1684 | 1686 | |
| 1685 | 1687 | /* |
| 1686 | 1688 | ** Impl of /json/rebuild. Requires admin previleges. |
| 1687 | 1689 | |