小编mju*_*eri的帖子

Redux RTK 查询 invalidatesTags 突变后未调用

我一直在试图找出为什么标签失效不起作用并添加了一些日志记录。in工作正常,但providesTagsin从未被调用。可能出了什么问题?getMeinvalidatesTagslogin

我有一个像这样的 redux RTK 查询 API:

const baseQuery = fetchBaseQuery({
  baseUrl: baseUrl,
  prepareHeaders: (headers, { getState }) => {
    const token = getState().auth.token
    if (token) {
      headers.set('authorization', `Bearer ${token}`)
    }
    return headers
  },
})

export const api = createApi({
  baseQuery: baseQuery,
  tagTypes: ['User'],
  endpoints: build => ({
    login: build.mutation({
      query: code => ({
        url: `auth/login/?code=${code}`,
        method: 'POST',
      }),
      invalidatesTags: (result, error, arg) => {
        console.log('auth/login', result, error, arg)
        return ['User']
      },
    }),
    getMe: build.query({
      query: …
Run Code Online (Sandbox Code Playgroud)

reactjs redux redux-toolkit rtk-query

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

Psycopg3:使用命名参数将列表作为 IN 语句的参数传递

如何使用 psycopg 的命名参数将列表传递给查询中的IN语句?

例子:

cur.execute("""
        SELECT name
        FROM users
        WHERE id IN (%(ids)s)
        """,
        {"ids": [1, 2, 3]})
Run Code Online (Sandbox Code Playgroud)

当我这样做时,我收到以下错误消息:

psycopg.errors.UndefinedFunction: operator does not exist: integer = smallint[]

HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
Run Code Online (Sandbox Code Playgroud)

python psycopg3

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

使用Ansible禁用EC2实例终止保护

我目前正在启用termination_protection使用Ansible创建的所有实例,以防止从控制台等意外终止。现在,我希望能够使用Ansible终止特定的实例,但我不知道如何在其上禁用终止保护。

我认为这可以解决问题:

- name: Disable termination protection
  ec2:
    instance_ids: "{{ instance_ids }}"
    region: "{{ aws_region }}"
    termination_protection: no
Run Code Online (Sandbox Code Playgroud)

运行该错误消息的方式:

fatal: [localhost]: FAILED! => {
  "changed": false, 
  "failed": true, 
  "msg": "image parameter is required for new instance"
}
Run Code Online (Sandbox Code Playgroud)

看起来Ansible会将我的脚本解释为实例创建请求。

有没有办法改变termination protection另一个模块?我唯一想到的另一种方法是通过Ansible中的一项任务使用aws clishell,但这有点麻烦。

amazon-ec2 ansible

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