允许参数化SQL查询的哪些部分?(What parts of a SQL query are allowed to be parameterized?)
例如,通常允许这样做:
sql.execute("select * from some_table where some_column=@parameter", parameter=5);
但不是这个:
sql.execute("select * from @which_table where some_column=5", which_table="some_table");
没有测试所有可能的组合......是这样的:
sql.execute("select @which_column from some_table", which_column="some_column");
或这个:
sql.execute("select some_column*@multiplier from some_table", multipler=5);
要么....
确定查询的某些部分是否可参数化的一般规则是什么?为什么?
(我意识到对于不同语言的不同数据库引擎和适配器,这可能有不同的答案,但我注意到有一般趋势)
For instance, this is generally allowed:
sql.execute("select * from some_table where some_column=@parameter", parameter=5);
But not this:
sql.execute("select * from @which_table where some_column=5", which_table="some_table");
Having not tested all possible combinations.... Is this:
sql.execute("select @which_column from some_table", which_column="some_column");
Or this:
sql.execute("select some_column*@multiplier from some_table", multipler=5);
Or....
What is the general rule for determining whether some part of a query is parameterizable, and why?
(I realize that this may have different answers with respect to different DB engines and adapters for different languages, but I've noticed that there are general trends)
原文:https://stackoverflow.com/questions/44315421
更新时间:2023-11-11 10:11
最满意答案
相关问答
更多-
对不起,没办法那样做。 您可以做的是在部署时添加额外的行。 $ npm install my_module $ NODE_ENV=production npm install 当你完成模块开发(假设你不想再链接它,因为它已经准备好生产)时,你只需删除那条额外的行并将它添加到你的依赖项中。 另一个想法是在部署脚本中修改package.json文件以进行生产。 这将确保仅为生产安装模块。 Sorry, there is no way to do that. What you could do is add ...
-
我应该只通过npm install安装node.js模块吗?(Should I install node.js modules through npm install only?)[2023-12-26]
npm install不只是将代码从Internet复制到node_modules。 安装可能还会编译平台的代码。 因此,如果您要从同一平台进行复制,那么应该没问题。 尽管如此,根据环境,某些模块可能无法工作。 npm install doesn't just copy code from the Internet to node_modules. The installation might also compile code for the platform. So if you are copying ... -
一切似乎都工作正常。 唯一需要记住的是npm是node.js的工具,这意味着您可以将其用于与节点本身相关的某些需求(就像Python中的pip或RoR中的bundler一样)。 所以你可以做的是: 安装express.js。 这是在node.js中工作的第一件事情。 跑: npm install express-generator -g 这将在系统上而不是在应用程序上安装express(这意味着你的问题出现,因为你试图安装节点模块而不是在应用程序目录中)。 然后创建一个你计划使用你的应用程序的目录并转到那 ...
-
我前一段时间遇到过类似的问题。 尝试导航到C:\Users\%UserName%名为.npmrc的文件,然后将其删除。 I had a similar problem a while ago. Try navigating to the file named .npmrc, in C:\Users\%UserName%, and deleting it.
-
原版scribe-js是根据麻省理工学院的许可证发布的,这意味着你基本上可以用包装做你想做的事情,甚至修改和销售它,但你必须保留版权和许可证本身的标志。 Original scribe-js is published under MIT license, what means you can basically do what you want with the package, even modify and sell it, but you must keep the indication of cop ...
-
首先尝试清理npm缓存: rm -rf ~/.npm npm cache clear 下一步,您可以尝试重建现有的包: npm rebuild 也有人说,Node版本5.1可以解决这个问题: 放入节点5后,npm ERR! 代码EINVALIDTYPE? Try to clean your npm cache at first: rm -rf ~/.npm npm cache clear Next step you could try to rebuild your existing packages: n ...
-
注册表URL指向https,试试这个 npm config set registry="http://registry.npmjs.org/" 然后尝试安装模块。 您可能是阻止安全(https)连接的代理。 The registry URL is pointing to https, try this npm config set registry="http://registry.npmjs.org/" and then try installing the module. You are behin ...
-
看一下docs http://nodejs.org/docs/latest/api/modules.html : 在节点中,文件和模块是一一对应的。 另一方面,package是一个包含特殊package.json文件的文件夹。 该文件告诉解释器如何在require(folder);时加载模块require(folder); 。 换句话说,package是模块的集合。 Have a look at docs http://nodejs.org/docs/latest/api/modules.html : In ...
-
未使用相对路径引用的节点模块的NPM解析是首先检查当前目录,然后向上遍历每个目录,查找node_modules文件夹。 所以在你的情况下,如果你想要相同的软件包/模块的相同版本,只需在main中安装: 最后,您可以全局安装所需的软件包/模块 - 但是,这通常仅建议您从命令行所需的软件包(例如gulp,webpack等)。 在你的情况下,对于特定于应用程序的模块,最好将它们保存在本地安装在node_modules文件夹下。 关于安装npm软件包的一些有用的NPM文档: 请参阅“从node_modules文件夹 ...
-
嗯,正确的做法是向维护者提交补丁,以便可以在上游(长期)修复。 同时,只需保留修改后的文件,安装主包后,重命名原始文件( mv file.js file.js.ORIG ),然后在副本中复制符号链接( ln -s ../../../patches/jsdom/level2/languages/file.js file.js )。 这是一个快速和肮脏的选择。 另一种选择是使用修改后的源代码和点NPM来构建新的npm tarball。 npm install命令可以将本地文件系统路径导入.tar.gz存档。 那 ...