ActiveRecord::ConnectionAdapters::SQLite3Adapter 不支持跳过重复项

ActiveRecord::ConnectionAdapters::SQLite3Adapter does not support skipping duplicates

我在尝试对 Github 操作进行 运行 rspec 时遇到了这个问题。这是我的 github 操作流程。

name: Ruby

on:
  push:
    branches: [ master]
  pull_request:
    branches: [ master]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2
      - name: Setup System
        run: |
          sudo apt-get install sqlite3 libsqlite3-dev
      - name: Set up Ruby 2.7.2
        uses: actions/setup-ruby@v1
        with:
          ruby-version: 2.7.2
      - name: Cache Ruby Gems
        uses: actions/cache@v2
        with:
          path: vendor/bundle
          key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-gems-
      - name: Bundle Install
        run: |
          bundle config path vendor/bundle
          bundle install --jobs 4 --retry 3 --without=production
      - name: Setup DB
        env:
          RAILS_ENV: test
          DISABLE_SPRING: 1
        run: |
          bin/rails db:setup db:migrate db:seed
      - name: Run rspec
        env:
          RAILS_ENV: test
          DISABLE_SPRING: 1
        run: bundle exec rspec

tl;dr - 我使用的是旧版本的 SQLite3

好的,跟踪 rail 的代码,我发现它调用了 sqlite3 适配器

https://github.com/rails/rails/blob/da418dc2508eb8af94ba88b70034021cd17b1abd/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L152

调用

https://github.com/rails/rails/blob/da418dc2508eb8af94ba88b70034021cd17b1abd/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L149

指定 sqlite3 必须是 3.24.0 或更高版本。

同时,Github的ubuntu-当前最新(02-2021)使用Ubuntu 18作为“最新”。

并且 Ubuntu 上的 sqlite3 包默认安装 sqlite 3.22。来源:https://packages.ubuntu.com/search?keywords=sqlite3

所以改成runs-on: ubuntu-20.04后我就不再遇到这个问题了!