[Mysql Driver] Prepared Statements vs. Sprintf give me different types.

blov · · 405 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I have a database with lots of null values. Because of this I&#39;m using the technique of passing them all as string pointers, as described in the docs. <a href="http://pastebin.com/S1y0RT8g" rel="nofollow">SAMPLE CODE</a></p> <p>I wrote some queries and used fmt.Sprintf to build some queries. After some refactoring to substitute that code for prepared statements, my types all became their actual database types and I&#39;m getting error messages like: &#34;type is int64, not string&#34;.</p> <p>I already went back to using Sprintf. It&#39;s a small project and my vars are not user input, so not really a problem. But I&#39;d really like to know what&#39;s going on, because I&#39;m investing in becoming a Go dev in the long run.</p> <hr/>**评论:**<br/><br/>Ploobers: <pre><p>Show us your actual query. Prepared statements work great, so I&#39;m sure you just have a syntax error.</p></pre>palitones: <pre><p>Here you go. Thanks for the help!</p> <p><a href="http://pastebin.com/143AJJW1" rel="nofollow">http://pastebin.com/143AJJW1</a></p></pre>Ploobers: <pre><p>I&#39;m assuming that in your code, there&#39;s a closing &#34; in the prepared statement version. If not and it somehow compiled, that could cause weird issues.</p> <p>What field type is <code>t2.date_referenced</code>? DATETIME? TIMESTAMP?</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

405 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传