GVKun编程网logo

Rails PG :: UndefinedTable:错误:缺少表的FROM子句条目(ora00936缺少表达式)

8

如果您对RailsPG::UndefinedTable:错误:缺少表的FROM子句条目感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于RailsPG::UndefinedTa

如果您对Rails PG :: UndefinedTable:错误:缺少表的FROM子句条目感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于Rails PG :: UndefinedTable:错误:缺少表的FROM子句条目的详细内容,我们还将为您解答ora00936缺少表达式的相关问题,并且为您提供关于ActiveStorage:按附件文件名排序 ActiveRecord 模型(错误缺少表“active_storage_blobs”的 FROM 子句条目)、android – bundling failed:错误:插件0提供了“default”的无效属性、golang 编译错误:"undefined: file.Stat" 如何解决?、golang 编译错误:"undefined: ioutil.WriteFile" 如何解决?的有价值信息。

本文目录一览:

Rails PG :: UndefinedTable:错误:缺少表的FROM子句条目(ora00936缺少表达式)

Rails PG :: UndefinedTable:错误:缺少表的FROM子句条目(ora00936缺少表达式)

我有模特

class Offer < ActiveRecord::Base  belongs_to :agencyendclass Agency < ActiveRecord::Base  has_many :offersend

当我发出这样的请求时-一切都很好

@offers = Offer.with_state(:confirmed).  includes(:destination, :cruise_line, :ship).  paginate(per_page: 10, page: params[:page]).decorate

但我想只选择属于报价active机构(列stateagencies,所以我尝试做这样的表),:

@offers = Offer.with_state(:confirmed).  includes(:destination, :cruise_line, :ship).  joins(:agency).  where(agency: {state: ''active''}).  paginate(per_page: 10, page: params[:page]).decorate

完成此操作后,我会出错PG::UndefinedTable: ERROR: missing FROM-clause entry for table"agency"。我的代码有什么问题?

查询给我这个错误和SQL:

PG::UndefinedTable: ERROR: missing FROM-clause entry for table "agency" LINE 1: ...id" WHERE ("offers"."state" IN (''confirmed'')) AND "agency"."... ^ : SELECT "offers"."id" AS t0_r0, "offers"."name" AS t0_r1, "offers"."destination_id" AS t0_r2, "offers"."cruise_line_id" AS t0_r3, "offers"."ship_id" AS t0_r4, "offers"."departure_date" AS t0_r5, "offers"."departure_port_id" AS t0_r6, "offers"."arrival_date" AS t0_r7, "offers"."arrival_port_id" AS t0_r8, "offers"."flight_price" AS t0_r9, "offers"."bonus" AS t0_r10, "offers"."itinerary" AS t0_r11, "offers"."board_language_id" AS t0_r12, "offers"."agency_landing_page" AS t0_r13, "offers"."benefits" AS t0_r14, "offers"."inner_price" AS t0_r15, "offers"."inner_price_normal" AS t0_r16, "offers"."outer_price" AS t0_r17, "offers"."outer_price_normal" AS t0_r18, "offers"."balcony_price" AS t0_r19, "offers"."balcony_price_normal" AS t0_r20, "offers"."suite_price" AS t0_r21, "offers"."suite_price_normal" AS t0_r22, "offers"."lucky_price" AS t0_r23, "offers"."lucky_price_normal" AS t0_r24, "offers"."valid_from" AS t0_r25, "offers"."valid_till" AS t0_r26, "offers"."created_at" AS t0_r27, "offers"."updated_at" AS t0_r28, "offers"."description" AS t0_r29, "offers"."agency_id" AS t0_r30, "offers"."state" AS t0_r31, "destinations"."id" AS t1_r0, "destinations"."name" AS t1_r1, "destinations"."created_at" AS t1_r2, "destinations"."updated_at" AS t1_r3, "cruise_lines"."id" AS t2_r0, "cruise_lines"."name" AS t2_r1, "cruise_lines"."created_at" AS t2_r2, "cruise_lines"."updated_at" AS t2_r3, "ships"."id" AS t3_r0, "ships"."name" AS t3_r1, "ships"."picture" AS t3_r2, "ships"."cruise_line_id" AS t3_r3, "ships"."created_at" AS t3_r4, "ships"."updated_at" AS t3_r5 FROM "offers" INNER JOIN "agencies" ON "agencies"."id" = "offers"."agency_id" LEFT OUTER JOIN "destinations" ON "destinations"."id" = "offers"."destination_id" LEFT OUTER JOIN "cruise_lines" ON "cruise_lines"."id" = "offers"."cruise_line_id" LEFT OUTER JOIN "ships" ON "ships"."id" = "offers"."ship_id" WHERE ("offers"."state" IN (''confirmed'')) AND "agency"."state" = ''active'' LIMIT 10 OFFSET 0

答案1

小编典典

您添加的唯一内容是-where子句。似乎有问题:

where(agency: {state: ''active''})

…并产生错误的条件,因为在这种情况下,哈希键应表示表名。您可能应该有以下内容:

where(agencies: {state: ''active''})

更新

看到这一点吸引了很多关注,我想我还应该建议一种不同的方法来做同样的事情,它稍微有些可组合:

merge( Agency.where(state: ''active'') )

这个更好吗?它不对模型的表名做任何假设(并非在大多数情况下都很重要),并允许您使用 范围

# Inside Agencyscope :active, -> { where(state: ''active'') }# Somewhere elsemerge(Agency.active)

ActiveStorage:按附件文件名排序 ActiveRecord 模型(错误缺少表“active_storage_blobs”的 FROM 子句条目)

ActiveStorage:按附件文件名排序 ActiveRecord 模型(错误缺少表“active_storage_blobs”的 FROM 子句条目)

如何解决ActiveStorage:按附件文件名排序 ActiveRecord 模型(错误缺少表“active_storage_blobs”的 FROM 子句条目)?

我正在构建一个带有网页的 Rails 应用程序,该网页显示按报价文档的 PDF 创建日期排序的 QuoteDocuments 列表,该列表通过 ActiveStorage 附加

class Quote < ApplicationRecord
  has_many :quote_documents,dependent: :destroy
end
class QuoteDocument < ApplicationRecord
  has_one_attached :document
end

这是我正在使用的代码行,它给了我一个错误

@quote.quote_documents.includes(:document_attachment).order(''active_storage_blobs.filename ASC'')

这是错误

ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: missing FROM-clause entry for table "active_storage_blobs")

和 sql 语句

: SELECT "quote_documents"."id" AS t0_r0,"quote_documents"."quote_id" AS t0_r1,"quote_documents"."version" AS t0_r2,"quote_documents"."created_at" AS t0_r3,"quote_documents"."updated_at" AS t0_r4,"quote_documents"."document_file_name" AS t0_r5,"quote_documents"."document_content_type" AS t0_r6,"quote_documents"."document_file_size" AS t0_r7,"quote_documents"."document_updated_at" AS t0_r8,"quote_documents"."document_type" AS t0_r9,"quote_documents"."description" AS t0_r10,"quote_documents"."user_id" AS t0_r11,"active_storage_attachments"."id" AS t1_r0,"active_storage_attachments"."name" AS t1_r1,"active_storage_attachments"."record_type" AS t1_r2,"active_storage_attachments"."record_id" AS t1_r3,"active_storage_attachments"."blob_id" AS t1_r4,"active_storage_attachments"."created_at" AS t1_r5 FROM "quote_documents" LEFT OUTER JOIN "active_storage_attachments" ON "active_storage_attachments"."record_id" = "quote_documents"."id" AND "active_storage_attachments"."record_type" = $1 AND "active_storage_attachments"."name" = $2 WHERE "quote_documents"."quote_id" = $3 AND "quote_documents"."document_type" = $4 ORDER BY active_storage_blobs.filename ASC LIMIT $5

知道我应该怎么做才能解决这个问题吗?

解决方法

您需要在设置 @quote 的原始语句中使用 include,而不是使用 @quote 变量:

@quote = Quote.includes(quote_documents: {document_attachment: :blob}).find(params[id])

在你的控制器中

那么在您看来,您应该可以使用:

@quote.quote_documents.order(''active_storage_blobs.filename ASC'')

android – bundling failed:错误:插件0提供了“default”的无效属性

android – bundling failed:错误:插件0提供了“default”的无效属性

我正在尝试使用此命令在我的AVD上运行react本机应用程序:
react-native run-android

但得到以下错误:

bundling Failed: Error: Plugin 0 specified in "C:\\Users\\ASUS\\test\\node_modules\\babel-preset-react-native\\index.js" provided an invalid property of "default" (While processing preset: "C:\\Users\\ASUS\\test\\node_modules\\babel-preset-react-native\\index.js")
    at Plugin.init (C:\Users\ASUS\test\node_modules\babel-core\lib\transformation\plugin.js:131:13)
    at Function.normalisePlugin (C:\Users\ASUS\test\node_modules\babel-core\lib\transformation\file\options\option-manager.js:152:12)
    at C:\Users\ASUS\test\node_modules\babel-core\lib\transformation\file\options\option-manager.js:184:30
    at Array.map (<anonymous>)
    at Function.normalisePlugins (C:\Users\ASUS\test\node_modules\babel-core\lib\transformation\file\options\option-manager.js:158:20)
    at OptionManager.mergeOptions (C:\Users\ASUS\test\node_modules\babel-core\lib\transformation\file\options\option-manager.js:234:36)
    at C:\Users\ASUS\test\node_modules\babel-core\lib\transformation\file\options\option-manager.js:265:14
    at C:\Users\ASUS\test\node_modules\babel-core\lib\transformation\file\options\option-manager.js:323:22
    at Array.map (<anonymous>)

.babelrc:

{
  "presets": [
    "react-native"
    "@babel/preset-flow"
  ]
}

package.json:

{
  "name": "test","version": "0.0.1","private": true,"scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start","test": "jest"
  },"dependencies": {
    "react": "16.4.1","react-native": "^0.55.4"
  },"devDependencies": {
    "babel-jest": "23.4.0","babel-preset-react-native": "5.0.2","jest": "23.4.1","react-test-renderer": "16.4.1"
  },"jest": {
    "preset": "react-native"
  }
}

我正在使用Windows,node.js v 8.11.3&反应原生v 0.55.4

我已经尝试过在互联网上推荐的所有内容(特别是github),但仍然没有运气.如果有人可以提供帮助,真的很感激.

解决方法

这是babel-preset-react-native中的错误

设置版本:

yarn remove babel-preset-react-native
yarn add babel-preset-react-native@2.1.0

golang 编译错误:

golang 编译错误:"undefined: file.Stat" 如何解决?

golang 是一门静态类型的编程语言,它的快速开发和高效性受到越来越多的开发者的欢迎。但是, 在实际的开发中,可能会遇到一些编译错误,例如 "undefined: file.stat" 这种错误。

这种错误通常是由于缺少必要的包或库所导致的。要解决这个问题,需要对代码进行深入的分析和排错。下面将介绍几种可能导致这种编译错误的原因以及相应的解决方法。

  1. 缺少必要的包或库

在 Golang 中,很多操作需要使用系统的库或第三方库。如果在代码中使用了某些功能,但却没有正确引入相应的库文件,就会发生编译错误。

解决这种错误的最简单办法就是添加相应的引入语句。例如,在处理文件信息时需要使用 "os" 库,可以在代码的开头添加引入语句:

import "os"
登录后复制

如果发现还有其他的引用不到,就需要进一步分析哪些库缺失。可以通过查看依赖关系或提示信息来确定缺失的包或库。

立即学习“go语言免费学习笔记(深入)”;

  1. 版本兼容性问题

在 Golang 中,随着版本的更新,有些库的接口和使用方法也发生了改变。如果代码中使用了过时的接口或方法,很可能会发生编译错误。

解决这种错误的方法是更新相应的库文件,或在代码中使用兼容的方法。如果是比较老的项目,可能需要进行代码升级以兼容新版本的库。

  1. 不匹配的操作系统

由于 Golang 是一门跨平台的编程语言,所以在不同的操作系统上运行时可能会出现不同的问题。如果编译或执行时发生了错误,可能是因为使用了不同的操作系统所导致的。

解决这种问题的方法是使用合适的操作系统、编译器和工具。这就需要针对目标操作系统进行编译和测试,确保代码的可移植性和跨平台性。

  1. 权限问题

在 Golang 中,像读取或写入文件这种操作会涉及到文件或目录的权限问题。如果当前用户没有足够的权限执行某些操作,就会发生编译错误。

解决这种问题的方法是在运行程序时,确定当前用户拥有执行所需操作的足够权限。如果权限被限制了,可以通过修改权限来解决问题。

总结

以上是几种可能导致 Golang 编译错误 "undefined: file.Stat" 的原因和相应的解决方法。在开发过程中,慎重处理这些问题,有助于提高代码的可靠性、可移植性和稳定性。同时,也要注重代码的规范性和可维护性,以便更快速地排查问题和提高开发效率。

以上就是golang 编译错误:"undefined: file.Stat" 如何解决?的详细内容,更多请关注php中文网其它相关文章!

golang 编译错误:

golang 编译错误:"undefined: ioutil.WriteFile" 如何解决?

golang是一种相对新颖的编程语言,在编写程序时可能会遇到各种问题。其中一个常见的问题就是”undefined: ioutil.writefile“,这个错误提示通常在编译程序时出现。解决这个问题需要进行一些操作,本文将详细介绍如何处理golang编译错误 undefined: ioutil.writefile。

首先,需要明确这个错误信息的含义。这个错误信息提示我们在代码中使用了ioutil.WriteFile()函数,但是编译器无法识别这个函数,也就是说,这个函数并没有被导入或者没有正确地导入相关的库。

那么,我们需要检查我们的代码是否正确地导入了相关的库,确保文件的权限是否正确。在Golang中,使用”io/ioutil“导入库以访问文件读写、目录操作和临时文件操作,因此,检查是否正确导入这个库非常关键。需要在代码文件的开头使用”import ioutil“语句导入ioutil库,这样才能在代码中使用ioutil.WriteFile()函数。

如果导入io/ioutil之后,仍然出现了undefined: ioutil.WriteFile错误,则很可能是Golang环境没有正确安装或者版本不一致所致。在这种情况下,我们需要重新安装Golang环境或者升级到最新版本。可以访问官方网站(https://golang.org/)找到最新的Golang版本并下载安装。

另外,我们也需要检查代码是否有语法错误,并且编写代码时应该注意遵循一定的规则。在Golang中,变量名要使用小写字母开头,函数名要使用大写字母开头。这些规则都是为了确保代码的可读性和可维护性。所以我们在编写代码时应该遵循这些规则,这样可以减少错误出现的可能性。

立即学习“go语言免费学习笔记(深入)”;

总之,当编译错误提示undefined: ioutil.WriteFile时,需要进行以下操作:

  1. 检查代码是否正确导入了相关的库(io/ioutil)
  2. 检查文件的权限是否正确
  3. 重新安装Golang环境或者升级到最新版本
  4. 检查代码是否有语法错误,并遵循Golang的规则

通过以上操作一般可以解决golang编译错误undefined: ioutil.WriteFile的问题。相信读者们通过阅读本文,已经了解了如何解决这个问题。在编写程序时,遇到错误不必惊慌失措,应该仔细排查问题并尝试解决。

以上就是golang 编译错误:"undefined: ioutil.WriteFile" 如何解决?的详细内容,更多请关注php中文网其它相关文章!

今天关于Rails PG :: UndefinedTable:错误:缺少表的FROM子句条目ora00936缺少表达式的分享就到这里,希望大家有所收获,若想了解更多关于ActiveStorage:按附件文件名排序 ActiveRecord 模型(错误缺少表“active_storage_blobs”的 FROM 子句条目)、android – bundling failed:错误:插件0提供了“default”的无效属性、golang 编译错误:"undefined: file.Stat" 如何解决?、golang 编译错误:"undefined: ioutil.WriteFile" 如何解决?等相关知识,可以在本站进行查询。

本文标签: