diff --git a/insert.json b/insert.json new file mode 100644 index 0000000..0af1f0c --- /dev/null +++ b/insert.json @@ -0,0 +1,14 @@ +{ + "addcolumn": null, + "description": "tata", + "enddate": null, + "floatvalue": null, + "id": "1", + "intvalue": null, + "latitude": null, + "longitude": null, + "name": "toto", + "price": null, + "startdate": null, + "testtype_id": null +} \ No newline at end of file diff --git a/pg.go b/pg.go index c574a8b..7c5e011 100755 --- a/pg.go +++ b/pg.go @@ -519,6 +519,9 @@ func (db *Db) GenerateTableTemplates(templateFilename string, outputFolder strin } func FormatForSQL(datatype string, value interface{}) string { + if value == nil { + return "NULL" + } strval := fmt.Sprintf("%v", value) if !strings.Contains(datatype, "char") && len(strval) == 0 { return "NULL" diff --git a/pg_test.go b/pg_test.go index 61aa8d1..c24fde9 100755 --- a/pg_test.go +++ b/pg_test.go @@ -85,6 +85,11 @@ func TestInsert(t *testing.T) { if len(jsonStringOld) == len(jsonStringNew) { t.Errorf("Error row not created") } + jsonFile, err := os.Open("insert.json") + defer jsonFile.Close() + var result map[string]interface{} + byteValue, _ := ioutil.ReadAll(jsonFile) + json.Unmarshal(byteValue, &result) } func TestUpdate(t *testing.T) { diff --git a/swagger/favicon-16x16.png b/swagger/favicon-16x16.png new file mode 100644 index 0000000..0f7e13b Binary files /dev/null and b/swagger/favicon-16x16.png differ diff --git a/swagger/favicon-32x32.png b/swagger/favicon-32x32.png new file mode 100644 index 0000000..b0a3352 Binary files /dev/null and b/swagger/favicon-32x32.png differ diff --git a/swagger/index.html b/swagger/index.html new file mode 100644 index 0000000..d425107 --- /dev/null +++ b/swagger/index.html @@ -0,0 +1,93 @@ + + + +
+ +>>u&yn;if(_!==h>>>u&yn)break;_&&(l+=(1<i&&(c=c.removeBefore(r,u,a-l)),c&&h
a&&(a=c.size),o(u)||(c=c.map(function(e){return V(e)})),i.push(c)}return a>e.size&&(e=e.setSize(a)),Ie(e,t,i)}function $e(e){return es)return k();var e=i.next();return r||t===xn?e:t===bn?w(t,u-1,void 0,e):w(t,u-1,e.value[1],e)})},c}function dt(e,t,n){var r=Tt(e);return r.__iterateUncached=function(r,i){var o=this;if(i)return this.cacheResult().__iterate(r,i);var a=0;return e.__iterate(function(e,i,s){return t.call(n,e,i,s)&&++a&&r(e,i,o)}),a},r.__iteratorUncached=function(r,i){var o=this;if(i)return this.cacheResult().__iterator(r,i);var a=e.__iterator(wn,i),s=!0;return new x(function(){if(!s)return k();var e=a.next();if(e.done)return e;var i=e.value,u=i[0],c=i[1];return t.call(n,c,u,o)?r===wn?e:w(r,u,c,e):(s=!1,k())})},r}function mt(e,t,n,r){var i=Tt(e);return i.__iterateUncached=function(i,o){var a=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,u=0;return e.__iterate(function(e,o,c){if(!s||!(s=t.call(n,e,o,c)))return u++,i(e,r?o:u-1,a)}),u},i.__iteratorUncached=function(i,o){var a=this;if(o)return this.cacheResult().__iterator(i,o);var s=e.__iterator(wn,o),u=!0,c=0;return new x(function(){var e,o,l;do{if(e=s.next(),e.done)return r||i===xn?e:i===bn?w(i,c++,void 0,e):w(i,c++,e.value[1],e);var p=e.value;o=p[0],l=p[1],u&&(u=t.call(n,l,o,a))}while(u);return i===wn?e:w(i,o,l,e)})},i}function yt(e,t){var r=a(e),i=[e].concat(t).map(function(e){return o(e)?r&&(e=n(e)):e=r?L(e):z(Array.isArray(e)?e:[e]),e}).filter(function(e){return 0!==e.size});if(0===i.length)return e;if(1===i.length){var u=i[0];if(u===e||r&&a(u)||s(e)&&s(u))return u}var c=new I(i);return r?c=c.toKeyedSeq():s(e)||(c=c.toSetSeq()),c=c.flatten(!0),c.size=i.reduce(function(e,t){if(void 0!==e){var n=t.size;if(void 0!==n)return e+n}},0),c}function vt(e,t,n){var r=Tt(e);return r.__iterateUncached=function(r,i){function a(e,c){var l=this;e.__iterate(function(e,i){return(!t||c=Vn)return Oe(e,f,c,s,d);if(l&&!d&&2===f.length&&Ee(f[1^p]))return f[1^p];if(l&&d&&1===f.length&&Ee(d))return d;var m=e&&e===this.ownerID,y=l?d?c:c^u:c|u,v=l?d?Ne(f,p,d,m):Be(f,p,m):Fe(f,p,d,m);return m?(this.bitmap=y,this.nodes=v,this):new de(e,y,v)},me.prototype.get=function(e,t,n,r){void 0===t&&(t=oe(n));var i=(0===e?t:t>>>e)&yn,o=this.nodes[i];return o?o.get(e+dn,t,n,r):r},me.prototype.update=function(e,t,n,r,i,o,a){void 0===n&&(n=oe(r));var s=(0===t?n:n>>>t)&yn,u=i===vn,c=this.nodes,l=c[s];if(u&&!l)return this;var p=Se(l,e,t+dn,n,r,i,o,a);if(p===l)return this;var f=this.count;if(l){if(!p&&(f--,ft)return e.textContent;var o=function(e){for(var t,o,a,s,u,c=e.textContent,l=0,p=c[0],f=1,h=e.innerHTML="",d=0;o=t,t=d<7&&"\\"==t?1:f;){if(f=p,p=c[++l],s=h.length>1,!f||d>8&&"\n"==f||[/\S/[i](f),1,1,!/[$\w]/[i](f),("/"==t||"\n"==t)&&s,'"'==t&&s,"'"==t&&s,c[l-4]+o+t=="-->",o+t=="*/"][d])for(h&&(e[r](u=n.createElement("span")).setAttribute("style",["color: #555; font-weight: bold;","","","color: #555;",""][d?d<3?2:d>6?4:d>3?3:+/^(a(bstract|lias|nd|rguments|rray|s(m|sert)?|uto)|b(ase|egin|ool(ean)?|reak|yte)|c(ase|atch|har|hecked|lass|lone|ompl|onst|ontinue)|de(bugger|cimal|clare|f(ault|er)?|init|l(egate|ete)?)|do|double|e(cho|ls?if|lse(if)?|nd|nsure|num|vent|x(cept|ec|p(licit|ort)|te(nds|nsion|rn)))|f(allthrough|alse|inal(ly)?|ixed|loat|or(each)?|riend|rom|unc(tion)?)|global|goto|guard|i(f|mp(lements|licit|ort)|n(it|clude(_once)?|line|out|stanceof|t(erface|ernal)?)?|s)|l(ambda|et|ock|ong)|m(icrolight|odule|utable)|NaN|n(amespace|ative|ext|ew|il|ot|ull)|o(bject|perator|r|ut|verride)|p(ackage|arams|rivate|rotected|rotocol|ublic)|r(aise|e(adonly|do|f|gister|peat|quire(_once)?|scue|strict|try|turn))|s(byte|ealed|elf|hort|igned|izeof|tatic|tring|truct|ubscript|uper|ynchronized|witch)|t(emplate|hen|his|hrows?|ransient|rue|ry|ype(alias|def|id|name|of))|u(n(checked|def(ined)?|ion|less|signed|til)|se|sing)|v(ar|irtual|oid|olatile)|w(char_t|hen|here|hile|ith)|xor|yield)$/[i](h):0]),u[r](n.createTextNode(h))),a=d&&d<7?d:a,h="",d=11;![1,/[\/{}[(\-+*=<>:;|\\.,?!&@~]/[i](f),/[\])]/[i](f),/[$\w]/[i](f),"/"==f&&a<2&&"<"!=t,'"'==f,"'"==f,f+p+c[l+1]+c[l+2]=="':null;var r=e.$$ref.match(/\S*\/(\S+)$/);e.xml.name=r[1]}return(0,z.memoizedCreateXMLExample)(e,n)}return JSON.stringify((0,z.memoizedSampleFromSchema)(e,n),null,2)},t.parseSeach=function(){var e={},t=window.location.search;if(""!=t){var n=t.substr(1).split("&");for(var r in n)r=n[r].split("="),e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e},t.btoa=function(t){var n=void 0;return n=t instanceof e?t:new e(t.toString(),"utf-8"),n.toString("base64")},t.sorters={operationsSorter:{alpha:function(e,t){return e.get("path").localeCompare(t.get("path"))},method:function(e,t){return e.get("method").localeCompare(t.get("method"))}}},t.buildFormData=function(e){var t=[];for(var n in e){var r=e[n];void 0!==r&&""!==r&&t.push([n,"=",encodeURIComponent(r).replace(/%20/g,"+")].join(""))}return t.join("&")},t.filterConfigs=function(e,t){var n=void 0,r={};for(n in e)t.indexOf(n)!==-1&&(r[n]=e[n]);return r}}).call(t,n(299).Buffer)},function(e,t,n){"use strict";var r=n(337);e.exports=function(e,t,n,i){var o=n?n.call(i,e,t):void 0;if(void 0!==o)return!!o;if(e===t)return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var a=r(e),s=r(t),u=a.length;if(u!==s.length)return!1;i=i||null;for(var c=Object.prototype.hasOwnProperty.bind(t),l=0;l-1&&e%1==0&&e","
"],l=[3,"
"],p=[1,'"],f={"*":[1,"?","
"],legend:[1,""],param:[1,""],tr:[2,"","
"],optgroup:u,option:u,caption:c,colgroup:c,tbody:c,tfoot:c,thead:c,td:l,th:l},h=["circle","clipPath","defs","ellipse","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","text","tspan"];h.forEach(function(e){f[e]=p,s[e]=!0}),e.exports=r},function(e,t,n){"use strict";var r=n(694),i=n(653),o={dangerouslyProcessChildrenUpdates:function(e,t){var n=i.getNodeFromInstance(e);r.processUpdates(n,t)}};e.exports=o},function(e,t,n){"use strict";function r(e){if(e){var t=e._currentElement._owner||null;if(t){var n=t.getName();if(n)return" This DOM node was rendered by `"+n+"`."}}return""}function i(e,t){t&&(G[e._tag]&&(null!=t.children||null!=t.dangerouslySetInnerHTML?m("137",e._tag,e._currentElement._owner?" Check the render method of "+e._currentElement._owner.getName()+".":""):void 0),null!=t.dangerouslySetInnerHTML&&(null!=t.children?m("60"):void 0,"object"==typeof t.dangerouslySetInnerHTML&&U in t.dangerouslySetInnerHTML?void 0:m("61")),null!=t.style&&"object"!=typeof t.style?m("62",r(e)):void 0)}function o(e,t,n,r){if(!(r instanceof I)){var i=e._hostContainerInfo,o=i._node&&i._node.nodeType===K,s=o?i._node:i._ownerDocument;B(t,s),r.getReactMountReady().enqueue(a,{inst:e,registrationName:t,listener:n})}}function a(){var e=this;k.putListener(e.inst,e.registrationName,e.listener)}function s(){var e=this;T.postMountWrapper(e)}function u(){var e=this;M.postMountWrapper(e)}function c(){var e=this;O.postMountWrapper(e)}function l(){var e=this;e._rootNodeID?void 0:m("63");var t=F(e);switch(t?void 0:m("64"),e._tag){case"iframe":case"object":e._wrapperState.listeners=[E.trapBubbledEvent("topLoad","load",t)];break;case"video":case"audio":e._wrapperState.listeners=[];for(var n in V)V.hasOwnProperty(n)&&e._wrapperState.listeners.push(E.trapBubbledEvent(n,V[n],t));break;case"source":e._wrapperState.listeners=[E.trapBubbledEvent("topError","error",t)];break;case"img":e._wrapperState.listeners=[E.trapBubbledEvent("topError","error",t),E.trapBubbledEvent("topLoad","load",t)];break;case"form":e._wrapperState.listeners=[E.trapBubbledEvent("topReset","reset",t),E.trapBubbledEvent("topSubmit","submit",t)];break;case"input":case"select":case"textarea":e._wrapperState.listeners=[E.trapBubbledEvent("topInvalid","invalid",t)]}}function p(){D.postUpdateWrapper(this)}function f(e){$.call(Y,e)||(X.test(e)?void 0:m("65",e),Y[e]=!0)}function h(e,t){return e.indexOf("-")>=0||null!=t.is}function d(e){var t=e.type;f(t),this._currentElement=e,this._tag=t.toLowerCase(),this._namespaceURI=null,this._renderedChildren=null,this._previousStyle=null,this._previousStyleCopy=null,this._hostNode=null,this._hostParent=null,this._rootNodeID=0,this._domID=0,this._hostContainerInfo=null,this._wrapperState=null,this._topLevelWrapper=null,this._flags=0}var m=n(654),y=n(623),v=n(707),g=n(709),_=n(695),b=n(696),x=n(655),w=n(717),k=n(661),S=n(662),E=n(719),C=n(656),A=n(653),T=n(722),O=n(725),D=n(726),M=n(727),P=(n(681),n(728)),I=n(746),j=(n(631),n(700)),R=(n(627),n(684),n(735),n(749),n(630),C),N=k.deleteListener,F=A.getNodeFromInstance,B=E.listenTo,L=S.registrationNameModules,z={string:!0,number:!0},q="style",U="__html",W={children:null,dangerouslySetInnerHTML:null,suppressContentEditableWarning:null},K=11,V={topAbort:"abort",topCanPlay:"canplay",topCanPlayThrough:"canplaythrough",topDurationChange:"durationchange",topEmptied:"emptied",topEncrypted:"encrypted",topEnded:"ended",topError:"error",topLoadedData:"loadeddata",topLoadedMetadata:"loadedmetadata",topLoadStart:"loadstart",topPause:"pause",topPlay:"play",topPlaying:"playing",topProgress:"progress",topRateChange:"ratechange",topSeeked:"seeked",topSeeking:"seeking",topStalled:"stalled",topSuspend:"suspend",topTimeUpdate:"timeupdate",topVolumeChange:"volumechange",topWaiting:"waiting"},H={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},J={listing:!0,pre:!0,textarea:!0},G=y({menuitem:!0},H),X=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,Y={},$={}.hasOwnProperty,Z=1;d.displayName="ReactDOMComponent",d.Mixin={mountComponent:function(e,t,n,r){this._rootNodeID=Z++,this._domID=n._idCounter++,this._hostParent=t,this._hostContainerInfo=n;var o=this._currentElement.props;switch(this._tag){case"audio":case"form":case"iframe":case"img":case"link":case"object":case"source":case"video":this._wrapperState={listeners:null},e.getReactMountReady().enqueue(l,this);break;case"input":T.mountWrapper(this,o,t),o=T.getHostProps(this,o),e.getReactMountReady().enqueue(l,this);break;case"option":O.mountWrapper(this,o,t),o=O.getHostProps(this,o);break;case"select":D.mountWrapper(this,o,t),o=D.getHostProps(this,o),e.getReactMountReady().enqueue(l,this);break;case"textarea":M.mountWrapper(this,o,t),o=M.getHostProps(this,o),e.getReactMountReady().enqueue(l,this)}i(this,o);var a,p;null!=t?(a=t._namespaceURI,p=t._tag):n._tag&&(a=n._namespaceURI,p=n._tag),(null==a||a===b.svg&&"foreignobject"===p)&&(a=b.html),a===b.html&&("svg"===this._tag?a=b.svg:"math"===this._tag&&(a=b.mathml)),this._namespaceURI=a;var f;if(e.useCreateElement){var h,d=n._ownerDocument;if(a===b.html)if("script"===this._tag){var m=d.createElement("div"),y=this._currentElement.type;m.innerHTML="<"+y+">"+y+">",h=m.removeChild(m.firstChild)}else h=o.is?d.createElement(this._currentElement.type,o.is):d.createElement(this._currentElement.type);else h=d.createElementNS(a,this._currentElement.type);A.precacheNode(this,h),this._flags|=R.hasCachedChildNodes,this._hostParent||w.setAttributeForRoot(h),this._updateDOMProperties(null,o,e);var g=_(h);this._createInitialChildren(e,o,r,g),f=g}else{var x=this._createOpenTagMarkupAndPutListeners(e,o),k=this._createContentMarkup(e,o,r);f=!k&&H[this._tag]?x+"/>":x+">"+k+""+this._currentElement.type+">"}switch(this._tag){case"input":e.getReactMountReady().enqueue(s,this),o.autoFocus&&e.getReactMountReady().enqueue(v.focusDOMComponent,this);break;case"textarea":e.getReactMountReady().enqueue(u,this),o.autoFocus&&e.getReactMountReady().enqueue(v.focusDOMComponent,this);break;case"select":o.autoFocus&&e.getReactMountReady().enqueue(v.focusDOMComponent,this);break;case"button":o.autoFocus&&e.getReactMountReady().enqueue(v.focusDOMComponent,this);break;case"option":e.getReactMountReady().enqueue(c,this)}return f},_createOpenTagMarkupAndPutListeners:function(e,t){var n="<"+this._currentElement.type;for(var r in t)if(t.hasOwnProperty(r)){var i=t[r];if(null!=i)if(L.hasOwnProperty(r))i&&o(this,r,i,e);else{r===q&&(i&&(i=this._previousStyleCopy=y({},t.style)),i=g.createMarkupForStyles(i,this));var a=null;null!=this._tag&&h(this._tag,t)?W.hasOwnProperty(r)||(a=w.createMarkupForCustomAttribute(r,i)):a=w.createMarkupForProperty(r,i),a&&(n+=" "+a)}}return e.renderToStaticMarkup?n:(this._hostParent||(n+=" "+w.createMarkupForRoot()),n+=" "+w.createMarkupForID(this._domID))},_createContentMarkup:function(e,t,n){var r="",i=t.dangerouslySetInnerHTML;if(null!=i)null!=i.__html&&(r=i.__html);else{var o=z[typeof t.children]?t.children:null,a=null!=o?null:t.children;if(null!=o)r=j(o);else if(null!=a){var s=this.mountChildren(a,e,n);r=s.join("")}}return J[this._tag]&&"\n"===r.charAt(0)?"\n"+r:r},_createInitialChildren:function(e,t,n,r){var i=t.dangerouslySetInnerHTML;if(null!=i)null!=i.__html&&_.queueHTML(r,i.__html);else{var o=z[typeof t.children]?t.children:null,a=null!=o?null:t.children;if(null!=o)""!==o&&_.queueText(r,o);else if(null!=a)for(var s=this.mountChildren(a,e,n),u=0;u-1&&(s=o?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n"))):s=e.stylize("[Circular]","special")),x(a)){if(o&&i.match(/^\d+$/))return s;a=JSON.stringify(""+i),a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function h(e,t,n){var r=0,i=e.reduce(function(e,t){return r++,t.indexOf("\n")>=0&&r++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function d(e){return Array.isArray(e)}function m(e){return"boolean"==typeof e}function y(e){return null===e}function v(e){return null==e}function g(e){return"number"==typeof e}function _(e){return"string"==typeof e}function b(e){return"symbol"==typeof e}function x(e){return void 0===e}function w(e){return k(e)&&"[object RegExp]"===T(e)}function k(e){return"object"==typeof e&&null!==e}function S(e){return k(e)&&"[object Date]"===T(e)}function E(e){return k(e)&&("[object Error]"===T(e)||e instanceof Error)}function C(e){return"function"==typeof e}function A(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function T(e){return Object.prototype.toString.call(e)}function O(e){return e<10?"0"+e.toString(10):e.toString(10)}function D(){var e=new Date,t=[O(e.getHours()),O(e.getMinutes()),O(e.getSeconds())].join(":");return[e.getDate(),R[e.getMonth()],t].join(" ")}function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var P=/%[sdj%]/g;t.format=function(e){if(!_(e)){for(var t=[],n=0;nn?p.push([l,s]):i[s]=this.yaml_path_resolvers[l][s]);else for(d=this.yaml_path_resolvers,a=0,c=d.length;a=h){o.push(x[r.op].call(r,l,i,e));break}if(E(l)){if("-"===i)i=l.length;else{if(n&&!p(i))throw new C("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",a-1,r.path,r);i=parseInt(i,10)}if(f>=h){if(n&&"add"===r.op&&i>l.length)throw new C("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",a-1,r.path,r);o.push(b[r.op].call(r,l,i,e));break}}else if(i&&i.indexOf("~")!=-1&&(i=i.replace(/~1/g,"/").replace(/~0/g,"~")),f>=h){o.push(_[r.op].call(r,l,i,e));break}l=l[i]}}return o}function h(e,t){var n=[];return l(e,t,n,""),n}function d(e,t){function n(){this.constructor=e}for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function m(e){if(void 0===e)return!0;if(e)if(E(e)){for(var t=0,n=e.length;t