小编Ana*_*mez的帖子

日期范围之间的Postgresql查询

我正在尝试查询我的postgresql数据库以返回日期在某个月份和年份的结果.换句话说,我想要一个月的所有价值观.

到目前为止,我能够做到的唯一方法是这样的:

SELECT user_id 
FROM user_logs 
WHERE login_date BETWEEN '2014-02-01' AND '2014-02-28'
Run Code Online (Sandbox Code Playgroud)

问题是我必须在查询表之前计算第一个日期和最后日期.有更简单的方法吗?

谢谢

sql postgresql date between

105
推荐指数
4
解决办法
17万
查看次数

如何覆盖与复数表和蛇形列有关的rails配置

因此,我正在构建一个应用程序,其中有一个用Rails编写的后端以及一个用Vue和Amplify编写的客户端。我的数据库是MySQL,我正在将AWS AppSync与GraphQL用作数据源(指向我的数据库)。

AWS Amplify具有一个框架,该框架使我可以使用一个简单的命令基于表名和列来生成模式amplify api add-graphql-datasource。但是因为我使用的是Rails迁移,所以我的数据库使用的是Rails约定:带有蛇形列的复数表。

现在,问题在于GraphQL模式非常丑陋,并且没有使用正确的约定(类型和输入的单数名称,带有驼峰式道具)。例:

我的后端进行了以下迁移:

class CreatePosts < ActiveRecord::Migration[6.0]
  def change
    create_table :posts do |t|
      t.belongs_to :site, null: false
      t.string :title
      t.string :url
      t.text :body

      t.timestamps
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

并且为此生成的模式是:

type posts {
  id: Int!
  site_id: Int!
  title: String
  url: String
  body: String
  created_at: AWSDateTime!
  updated_at: AWSDateTime!
}

type Query {
  getPosts(id: Int!): posts
  listPostss: [posts]
  // ...
}

schema {
  query: Query
  // ...
}
Run Code Online (Sandbox Code Playgroud)

更不用说了:

input CreatepostsInput {
  id: Int!
  site_id: Int!
  title: …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails amazon-web-services graphql aws-amplify

8
推荐指数
1
解决办法
126
查看次数

捆绑版本不匹配 - bundler 2,ruby 2.6

我们刚刚将ruby更新为2.6,将bundler更新为2.现在我们得到:

# bin/rails console
You must use Bundler 2 or greater with this lockfile.
Run Code Online (Sandbox Code Playgroud)

以前发生过bundle exec:

# bundle exec rails console
You must use Bundler 2 or greater with this lockfile.
Run Code Online (Sandbox Code Playgroud)

那时我们默认仍然运行1.17.2:

# gem list bundler

*** LOCAL GEMS ***

bundler (2.0.1, default: 1.17.2)
Run Code Online (Sandbox Code Playgroud)

所以我们跑了gem uninstall bundler --version 1.17.2然后bundle exec开始工作.

但是bin存根bin/rails仍然是失败的.

1.17.2卸载后如何运行?

ruby ruby-on-rails bundler ruby-2.6

7
推荐指数
2
解决办法
3023
查看次数

golang中用于存储日期时间偏移量的数据类型

I am using go language to develop an application. In my program I receive a JSON data which contains an entity in date time offset format for example DateTime": "2014-10-19T23:08:24Z"

I need to unmarshal the JSON and store it in the database in the TIMESTAMP(p) WITH TIME ZONE format in PostgreSQL database. When I unmarshal, I need to store this in a variable of the same data type.

Is there a data type available in Golang to do this or …

postgresql datetime json go

5
推荐指数
1
解决办法
3474
查看次数

Ruby 2.6 / 2.7 中 `public_send` 的不同行为

class A
  def a
    1
  end
end

a = A.new
x = {}

a.a(**x) # => 1 in both Ruby 2.6 and 2.7

a.public_send(:a, **x) # => 1 in Ruby 2.7
Run Code Online (Sandbox Code Playgroud)

然而,在 Ruby 2.6 中:

ArgumentError: wrong number of arguments (given 1, expected 0) 
Run Code Online (Sandbox Code Playgroud)

这是 2.7 之前的错误public_send//send__send__?您建议如何克服这种差异?

您可以在此处实时检查此故障。

ruby keyword-argument ruby-2.6 ruby-2.7

1
推荐指数
1
解决办法
833
查看次数