首页 > 数据库 >nodejs sqlite报错 typeorm[ Expression tree is too large (maximum depth 1000)]

nodejs sqlite报错 typeorm[ Expression tree is too large (maximum depth 1000)]

时间:2023-07-23 22:14:43浏览次数:55  
标签:node sqlite nodejs month 报错 1000 typeorm

最近在给公司开发一个工具时,使用SQLite,然后突然发现报错:

(node:16195) UnhandledPromiseRejectionWarning: QueryFailedError: SQLITE_ERROR: Expression tree is too large (maximum depth 1000)
    at handler (/snapshot/server-work/node_modules/typeorm/driver/sqlite/SqliteQueryRunner.js:81:26)
    at Statement.errBack (/snapshot/server-work/node_modules/sqlite3/lib/sqlite3.js:15:21)
(Use `server-work --trace-warnings ...` to show where the warning was created)
(node:16195) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:16195) [DEP0018] Deprec

方法1

// 编译

tsc 
pkg -t win  package.json    

编译后运行程序时添加参数: --trace-warnings ,基本上可以解决报错,如果不能的话,请使用方法2

方法2

先看我的代码,查询当月的数据,然后执行remove进行删除查询到的数据,这个时候,typeorm最后会把你查的结果,使用id=xx or id=xxx 拼接,然后超过1000就会报错,解决方法就是使用IN,我这里就不直接查了后删除,直接根据条件直接删除

//先清空指定月的数据,然后进行添加
        // const currentMonthData= await this.workRepository.find({where:{month:month}})
        // await this.workRepository.remove(currentMonthData) //这里删除导致报错

由上面的代码修改成下面的代码

 await this.workRepository.createQueryBuilder().delete().where("month = :month ",{month:month})

你的代码如果有上面的报错,怎么办?

  • 开启SQL调试输出
  • 定位你SQL出问题的地方,一般是批量更新、批量删除的会经常出问题,重点关注这些,看是否是执行更新或删除时使用了结果作为参数

typeorm开启调试,指定logging级别即可

export const AppDataSource = new DataSource({
    type: "sqlite",
    database: config.sqliteConfig.dbname,
    synchronize: true,
    logging: ["query", "error"],
    entities: [User,Work],
    migrations: [User,Work],
    subscribers: [],
})

标签:node,sqlite,nodejs,month,报错,1000,typeorm
From: https://www.cnblogs.com/ssjt/p/17576022.html

相关文章

  • 解决python解析Excel文件报错xlrd.biffh.XLRDError: Excel xlsx file; not supported
    报错如下:解决方案:1、安装低版本xlrdpipinstallxlrd==1.2.02、Excel另存为的时候将后缀改为.xls文件再修改代码的文件后缀即可,高版本的xlrd模块依旧支持读取.xls文件参考文章:https://blog.csdn.net/yuan2019035055/article/details/128408178......
  • WEB漏洞-查询方式及报错注入
    WEB漏洞-查询方式及报错注入目录WEB漏洞-查询方式及报错注入1.查询方式1.1select查询数据1.2insert插入数据1.3delete删除数据1.4update更新数据1.5orderby排序数据2.SQL注入报错盲注2.1基于布尔的SQL盲注-逻辑判断2.如何进行布尔盲注?3.靶场案例演示:总结归纳:2.2基......
  • springboot项目报错找不到mapper文件
    在使用SpringBoot中的MyBatis-Plus(简称MP)时,出现无法找到mapper.xml文件的错误,可能有以下几个原因:1.未正确配置mapper.xml文件路径:在SpringBoot中,可以通过在application.properties或application.yml文件中设置mybatis-plus.mapper-locations属性来指定mapper.xm......
  • Python报错 | AttributeError: 'NoneType' object has no attribute 'group'
    报错信息使用Python正则匹配的时候,报如下错误:AttributeError:'NoneType'objecthasnoattribute'group'错误原因报错翻译过来是:属性错误:“NoneType”对象没有属性“group”没有匹配到符合正则表达式的内容,但又调用了group方法。importrestr='hellopython!!!hel......
  • infraworks卸载不干净无法安装?一招教你如何搞定infraworks安装失败报错的问题【转载】
    infraworks专用卸载工具,完全彻底卸载删除干净infraworks各种残留注册表和文件的方法和步骤。如何卸载infraworks呢?有很多同学想把infraworks卸载后重新安装,但是发现infraworks安装到一半就失败了或者显示infraworks已安装或者安装未完成,大多数情况下其实是infraworks没有被卸载干......
  • java中tomcat 加载动态库XXX.dll报错“java.lang.UnsatisfiedLinkError: already load
    错误:在Tomcat项目和supermapiserverwar包中使用了相同的supermapjavaiobject【四个jar包】,实际的访问过程如下:这时候在访问Tomcat的时候,就会出现一个错误:anexceptioncaughtatEnvironment.loadLibrary(),programwillcontinuerunning.java.lang.UnsatisfiedL......
  • scanf在VS中报错
    为啥在VS中使用scanf,strcpystrlenstrcat等函数会有警告呢?scanf是c语言提供的函数,但函数本身自带安全性问题,微软工程师为了解决这些安全问题,在VS2013以上的版本上添加了scanf_s这类函数。scanf_svs编辑器提供的,虽然提高了安全性能,但移植性太差,故不建议使用。解决办法:1、打开......
  • reportlab报错“JPEG Unsupported JPEG marker: cb”
    报错信息reportlab.pdfbase.pdfdoc.PDFError:JPEGUnsupportedJPEGmarker:cbreportlab.pdfbase.pdfdoc.PDFError: ImagingLibrarynotavailable,unabletoimportbitmapsonlyjpegsfileName='PDFtool/data/img1.png'identity=[ImageReader@0x2866c5ad6f0f......
  • SqLite 生成序号(查询结果加上序号)
    SqLite生成序号(查询结果加上序号)表结构字段名称数据类型说明(可选)IDINTEGER序号NameTEXT(50)名称AmountREAL数量CREATETABLE[tCeShi]([ID]INTEGER,[Name]TEXT(50),[Amount]REAL);表中数据IDNameAmount1商品A302商......
  • ssh连接设置更改数据库名不起效果,连接127.0.0.1更换127.0.0.22也不报错
    ssh连接设置更改数据库名不起效果,连接127.0.0.1更换127.0.0.22也不报错 浏览器缓存清除后也一样。更换浏览器一样tomcat重启无效work目录全部删除无效myeclipse重新build工程无效重启myeclipse无效tomcat程序不指向工程下的webroot改为发布到webapp无效更换端口为8081的tomcat6无......