An Ecto SQLite3 adapter.
0

Configure Feed

Select the types of activity you want to include in your feed.

Adds credo checks to CI (#66)

* Adds credo
* Fix all credo issues and warnings
* Update CI to use credo

authored by

Matthew Johnston and committed by
GitHub
(Mar 16, 2022, 9:16 AM -0500) ce460b76 f544443d

+301 -91
+211
.credo.exs
··· 1 + # This file contains the configuration for Credo and you are probably reading 2 + # this after creating it with `mix credo.gen.config`. 3 + # 4 + # If you find anything wrong or unclear in this file, please report an 5 + # issue on GitHub: https://github.com/rrrene/credo/issues 6 + # 7 + %{ 8 + # 9 + # You can have as many configs as you like in the `configs:` field. 10 + configs: [ 11 + %{ 12 + # 13 + # Run any config using `mix credo -C <name>`. If no config name is given 14 + # "default" is used. 15 + # 16 + name: "default", 17 + # 18 + # These are the files included in the analysis: 19 + files: %{ 20 + # 21 + # You can give explicit globs or simply directories. 22 + # In the latter case `**/*.{ex,exs}` will be used. 23 + # 24 + included: [ 25 + "lib/", 26 + "src/", 27 + "test/", 28 + "web/", 29 + "apps/*/lib/", 30 + "apps/*/src/", 31 + "apps/*/test/", 32 + "apps/*/web/" 33 + ], 34 + excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"] 35 + }, 36 + # 37 + # Load and configure plugins here: 38 + # 39 + plugins: [], 40 + # 41 + # If you create your own checks, you must specify the source files for 42 + # them here, so they can be loaded by Credo before running the analysis. 43 + # 44 + requires: [], 45 + # 46 + # If you want to enforce a style guide and need a more traditional linting 47 + # experience, you can change `strict` to `true` below: 48 + # 49 + strict: false, 50 + # 51 + # To modify the timeout for parsing files, change this value: 52 + # 53 + parse_timeout: 5000, 54 + # 55 + # If you want to use uncolored output by default, you can change `color` 56 + # to `false` below: 57 + # 58 + color: true, 59 + # 60 + # You can customize the parameters of any check by adding a second element 61 + # to the tuple. 62 + # 63 + # To disable a check put `false` as second element: 64 + # 65 + # {Credo.Check.Design.DuplicatedCode, false} 66 + # 67 + checks: %{ 68 + enabled: [ 69 + # 70 + ## Consistency Checks 71 + # 72 + {Credo.Check.Consistency.ExceptionNames, []}, 73 + {Credo.Check.Consistency.LineEndings, []}, 74 + {Credo.Check.Consistency.ParameterPatternMatching, []}, 75 + {Credo.Check.Consistency.SpaceAroundOperators, []}, 76 + {Credo.Check.Consistency.SpaceInParentheses, []}, 77 + {Credo.Check.Consistency.TabsOrSpaces, []}, 78 + 79 + # 80 + ## Design Checks 81 + # 82 + # You can customize the priority of any check 83 + # Priority values are: `low, normal, high, higher` 84 + # 85 + {Credo.Check.Design.AliasUsage, 86 + [priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]}, 87 + 88 + # 89 + ## Readability Checks 90 + # 91 + {Credo.Check.Readability.AliasOrder, []}, 92 + {Credo.Check.Readability.FunctionNames, []}, 93 + {Credo.Check.Readability.LargeNumbers, []}, 94 + {Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]}, 95 + {Credo.Check.Readability.ModuleAttributeNames, []}, 96 + {Credo.Check.Readability.ModuleDoc, []}, 97 + {Credo.Check.Readability.ModuleNames, []}, 98 + {Credo.Check.Readability.ParenthesesInCondition, []}, 99 + {Credo.Check.Readability.ParenthesesOnZeroArityDefs, []}, 100 + {Credo.Check.Readability.PipeIntoAnonymousFunctions, []}, 101 + {Credo.Check.Readability.PredicateFunctionNames, []}, 102 + {Credo.Check.Readability.PreferImplicitTry, []}, 103 + {Credo.Check.Readability.RedundantBlankLines, []}, 104 + {Credo.Check.Readability.Semicolons, []}, 105 + {Credo.Check.Readability.SpaceAfterCommas, []}, 106 + {Credo.Check.Readability.StringSigils, []}, 107 + {Credo.Check.Readability.TrailingBlankLine, []}, 108 + {Credo.Check.Readability.TrailingWhiteSpace, []}, 109 + {Credo.Check.Readability.UnnecessaryAliasExpansion, []}, 110 + {Credo.Check.Readability.VariableNames, []}, 111 + {Credo.Check.Readability.WithSingleClause, []}, 112 + 113 + # 114 + ## Refactoring Opportunities 115 + # 116 + {Credo.Check.Refactor.Apply, []}, 117 + {Credo.Check.Refactor.CondStatements, []}, 118 + {Credo.Check.Refactor.CyclomaticComplexity, []}, 119 + {Credo.Check.Refactor.FunctionArity, []}, 120 + {Credo.Check.Refactor.LongQuoteBlocks, []}, 121 + {Credo.Check.Refactor.MatchInCondition, []}, 122 + {Credo.Check.Refactor.MapJoin, []}, 123 + {Credo.Check.Refactor.NegatedConditionsInUnless, []}, 124 + {Credo.Check.Refactor.NegatedConditionsWithElse, []}, 125 + {Credo.Check.Refactor.Nesting, []}, 126 + {Credo.Check.Refactor.UnlessWithElse, []}, 127 + {Credo.Check.Refactor.WithClauses, []}, 128 + {Credo.Check.Refactor.FilterFilter, []}, 129 + {Credo.Check.Refactor.RejectReject, []}, 130 + {Credo.Check.Refactor.RedundantWithClauseResult, []}, 131 + 132 + # 133 + ## Warnings 134 + # 135 + {Credo.Check.Warning.ApplicationConfigInModuleAttribute, []}, 136 + {Credo.Check.Warning.BoolOperationOnSameValues, []}, 137 + {Credo.Check.Warning.ExpensiveEmptyEnumCheck, []}, 138 + {Credo.Check.Warning.IExPry, []}, 139 + {Credo.Check.Warning.IoInspect, []}, 140 + {Credo.Check.Warning.OperationOnSameValues, []}, 141 + {Credo.Check.Warning.OperationWithConstantResult, []}, 142 + {Credo.Check.Warning.RaiseInsideRescue, []}, 143 + {Credo.Check.Warning.SpecWithStruct, []}, 144 + {Credo.Check.Warning.WrongTestFileExtension, []}, 145 + {Credo.Check.Warning.UnusedEnumOperation, []}, 146 + {Credo.Check.Warning.UnusedFileOperation, []}, 147 + {Credo.Check.Warning.UnusedKeywordOperation, []}, 148 + {Credo.Check.Warning.UnusedListOperation, []}, 149 + {Credo.Check.Warning.UnusedPathOperation, []}, 150 + {Credo.Check.Warning.UnusedRegexOperation, []}, 151 + {Credo.Check.Warning.UnusedStringOperation, []}, 152 + {Credo.Check.Warning.UnusedTupleOperation, []}, 153 + {Credo.Check.Warning.UnsafeExec, []} 154 + ], 155 + disabled: [ 156 + # 157 + # Checks scheduled for next check update (opt-in for now, just replace `false` with `[]`) 158 + 159 + # You can also customize the exit_status of each check. 160 + # If you don't want TODO comments to cause `mix credo` to fail, just 161 + # set this value to 0 (zero). 162 + # 163 + {Credo.Check.Design.TagTODO, [exit_status: 2]}, 164 + {Credo.Check.Design.TagFIXME, []}, 165 + 166 + # 167 + # Controversial and experimental checks (opt-in, just move the check to `:enabled` 168 + # and be sure to use `mix credo --strict` to see low priority checks) 169 + # 170 + {Credo.Check.Consistency.MultiAliasImportRequireUse, []}, 171 + {Credo.Check.Consistency.UnusedVariableNames, []}, 172 + {Credo.Check.Design.DuplicatedCode, []}, 173 + {Credo.Check.Design.SkipTestWithoutComment, []}, 174 + {Credo.Check.Readability.AliasAs, []}, 175 + {Credo.Check.Readability.BlockPipe, []}, 176 + {Credo.Check.Readability.ImplTrue, []}, 177 + {Credo.Check.Readability.MultiAlias, []}, 178 + {Credo.Check.Readability.NestedFunctionCalls, []}, 179 + {Credo.Check.Readability.SeparateAliasRequire, []}, 180 + {Credo.Check.Readability.SingleFunctionToBlockPipe, []}, 181 + {Credo.Check.Readability.SinglePipe, []}, 182 + {Credo.Check.Readability.Specs, []}, 183 + {Credo.Check.Readability.StrictModuleLayout, []}, 184 + {Credo.Check.Readability.WithCustomTaggedTuple, []}, 185 + {Credo.Check.Refactor.ABCSize, []}, 186 + {Credo.Check.Refactor.AppendSingleItem, []}, 187 + {Credo.Check.Refactor.DoubleBooleanNegation, []}, 188 + {Credo.Check.Refactor.FilterReject, []}, 189 + {Credo.Check.Refactor.IoPuts, []}, 190 + {Credo.Check.Refactor.MapMap, []}, 191 + {Credo.Check.Refactor.ModuleDependencies, []}, 192 + {Credo.Check.Refactor.NegatedIsNil, []}, 193 + {Credo.Check.Refactor.PipeChainStart, []}, 194 + {Credo.Check.Refactor.RejectFilter, []}, 195 + {Credo.Check.Refactor.VariableRebinding, []}, 196 + {Credo.Check.Warning.LazyLogging, []}, 197 + {Credo.Check.Warning.LeakyEnvironment, []}, 198 + {Credo.Check.Warning.MapGetUnsafePass, []}, 199 + {Credo.Check.Warning.MixEnv, []}, 200 + {Credo.Check.Warning.UnsafeToAtom, []} 201 + 202 + # {Credo.Check.Refactor.MapInto, []}, 203 + 204 + # 205 + # Custom checks can be created using `mix credo.gen.check`. 206 + # 207 + ] 208 + } 209 + } 210 + ] 211 + }
+6 -5
mix.exs
··· 38 38 {:ecto, "~> 3.7"}, 39 39 {:exqlite, "~> 0.9"}, 40 40 {:ex_doc, "~> 0.27", only: [:dev], runtime: false}, 41 - {:jason, ">= 0.0.0", only: [:bench, :test, :docs]}, 41 + {:jason, ">= 0.0.0", only: [:dev, :test, :docs]}, 42 42 {:temp, "~> 0.4", only: [:test]}, 43 + {:credo, "~> 1.6", only: [:dev, :test, :docs]}, 43 44 44 45 # Benchmarks 45 - {:benchee, "~> 1.0", only: :bench}, 46 - {:benchee_markdown, "~> 0.2", only: :bench}, 47 - {:postgrex, "~> 0.15.0", only: :bench}, 48 - {:myxql, "~> 0.5.0", only: :bench} 46 + {:benchee, "~> 1.0", only: :dev}, 47 + {:benchee_markdown, "~> 0.2", only: :dev}, 48 + {:postgrex, "~> 0.15.0", only: :dev}, 49 + {:myxql, "~> 0.5.0", only: :dev} 49 50 ] 50 51 end 51 52
+5 -2
mix.lock
··· 1 1 %{ 2 2 "benchee": {:hex, :benchee, "1.1.0", "f3a43817209a92a1fade36ef36b86e1052627fd8934a8b937ac9ab3a76c43062", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}, {:statistex, "~> 1.0", [hex: :statistex, repo: "hexpm", optional: false]}], "hexpm", "7da57d545003165a012b587077f6ba90b89210fd88074ce3c60ce239eb5e6d93"}, 3 3 "benchee_markdown": {:hex, :benchee_markdown, "0.2.7", "2b3967a8c49acb4a1fd4a5dc42fe3fc6d9713154dad4c9053b07997a951ec6c4", [:mix], [{:benchee, ">= 0.99.0 and < 2.0.0", [hex: :benchee, repo: "hexpm", optional: false]}], "hexpm", "c2ed04e0c8f7fb4aa75c3006973e14cca93adf2bf61713e421530dee63368b12"}, 4 + "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, 4 5 "connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"}, 6 + "credo": {:hex, :credo, "1.6.4", "ddd474afb6e8c240313f3a7b0d025cc3213f0d171879429bf8535d7021d9ad78", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "c28f910b61e1ff829bffa056ef7293a8db50e87f2c57a9b5c3f57eee124536b7"}, 5 7 "db_connection": {:hex, :db_connection, "2.4.2", "f92e79aff2375299a16bcb069a14ee8615c3414863a6fef93156aee8e86c2ff3", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "4fe53ca91b99f55ea249693a0229356a08f4d1a7931d8ffa79289b145fe83668"}, 6 8 "decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"}, 7 9 "deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"}, 8 - "earmark_parser": {:hex, :earmark_parser, "1.4.20", "89970db71b11b6b89759ce16807e857df154f8df3e807b2920a8c39834a9e5cf", [:mix], [], "hexpm", "1eb0d2dabeeeff200e0d17dc3048a6045aab271f73ebb82e416464832eb57bdd"}, 9 - "ecto": {:hex, :ecto, "3.7.1", "a20598862351b29f80f285b21ec5297da1181c0442687f9b8329f0445d228892", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d36e5b39fc479e654cffd4dbe1865d9716e4a9b6311faff799b6f90ab81b8638"}, 10 + "earmark_parser": {:hex, :earmark_parser, "1.4.22", "1de32345aab0d28bc208314937d2e69ff72ac6cacfdf89b1c0b75fc00283eb56", [:mix], [], "hexpm", "e10a2857c3b5333c503c7f95710c64f0beb2cfaa1d9de024513ad5242dc7cad5"}, 11 + "ecto": {:hex, :ecto, "3.7.2", "44c034f88e1980754983cc4400585970b4206841f6f3780967a65a9150ef09a8", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a600da5772d1c31abbf06f3e4a1ffb150e74ed3e2aa92ff3cee95901657a874e"}, 10 12 "ecto_sql": {:hex, :ecto_sql, "3.7.2", "55c60aa3a06168912abf145c6df38b0295c34118c3624cf7a6977cd6ce043081", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.4.0 or ~> 0.5.0 or ~> 0.6.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 0.16.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3c218ea62f305dcaef0b915fb56583195e7b91c91dcfb006ba1f669bfacbff2a"}, 11 13 "elixir_make": {:hex, :elixir_make, "0.6.3", "bc07d53221216838d79e03a8019d0839786703129599e9619f4ab74c8c096eac", [:mix], [], "hexpm", "f5cbd651c5678bcaabdbb7857658ee106b12509cd976c2c2fca99688e1daf716"}, 12 14 "ex_doc": {:hex, :ex_doc, "0.28.2", "e031c7d1a9fc40959da7bf89e2dc269ddc5de631f9bd0e326cbddf7d8085a9da", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "51ee866993ffbd0e41c084a7677c570d0fc50cb85c6b5e76f8d936d9587fa719"}, 13 15 "exqlite": {:hex, :exqlite, "0.10.2", "bb609c45ef5c8215dfe98dbf41a3b964ed0efc492f207c063e0584966b8f8d44", [:make, :mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "9727e053ba524e7526c801a7d8a2ac04ceb09fb4ab9b0b81c4128feb1e61d106"}, 16 + "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, 14 17 "jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"}, 15 18 "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"}, 16 19 "makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"},
+3 -1
test/test_helper.exs
··· 18 18 defmodule Ecto.Integration.Case do 19 19 use ExUnit.CaseTemplate 20 20 21 + alias Ecto.Adapters.SQL.Sandbox 22 + 21 23 setup do 22 - :ok = Ecto.Adapters.SQL.Sandbox.checkout(TestRepo) 24 + :ok = Sandbox.checkout(TestRepo) 23 25 # on_exit(fn -> Ecto.Adapters.SQL.Sandbox.checkin(TestRepo) end) 24 26 end 25 27 end
+34 -28
.github/workflows/ci.yml
··· 1 1 name: CI 2 2 3 3 on: 4 - pull_request: 5 4 push: 6 5 branches: 7 - - main 6 + - "*" 8 7 9 8 jobs: 10 9 lint: 11 - runs-on: ubuntu-20.04 10 + runs-on: ${{ matrix.os }} 12 11 env: 13 - MIX_ENV: test 12 + MIX_ENV: dev 14 13 name: Lint 14 + strategy: 15 + matrix: 16 + os: ["ubuntu-20.04"] 17 + elixir: ["1.13"] 18 + otp: ["24"] 15 19 steps: 16 20 - uses: actions/checkout@v2 17 - - uses: erlef/setup-elixir@v1 21 + - uses: erlef/setup-beam@v1 18 22 with: 19 - otp-version: "24" 20 - elixir-version: "1.12" 21 - - run: mix deps.get && mix deps.unlock --check-unused 23 + otp-version: ${{ matrix.otp }} 24 + elixir-version: ${{ matrix.elixir }} 25 + - uses: actions/cache@v2 26 + with: 27 + path: deps 28 + key: ${{ matrix.os }}-otp_${{ matrix.otp }}-elixir_${{ matrix.elixir }}-mix_${{ hashFiles('**/mix.lock') }} 29 + restore-keys: ${{ matrix.os }}-otp_${{ matrix.otp }}-elixir_${{ matrix.elixir }}-mix_ 30 + - run: mix deps.get 31 + - run: mix deps.compile 22 32 - run: mix format --check-formatted 33 + - run: mix deps.unlock --check-unused 34 + - run: mix credo --strict --all 35 + 23 36 test: 24 - runs-on: ubuntu-20.04 37 + runs-on: ${{ matrix.os }} 38 + name: Test Elixir ${{ matrix.elixir }}, OTP ${{ matrix.otp }}, OS ${{ matrix.os }} 25 39 env: 26 40 MIX_ENV: test 27 - name: Ubuntu / OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} 28 41 strategy: 29 42 fail-fast: false 30 43 matrix: 31 - include: 32 - - elixir: "1.12" 33 - otp: "24" 34 - - elixir: "1.12" 35 - otp: "23" 36 - - elixir: "1.11" 37 - otp: "24" 38 - - elixir: "1.11" 39 - otp: "23" 40 - - elixir: "1.10" 41 - otp: "24" 42 - - elixir: "1.10" 43 - otp: "23" 44 - - elixir: "1.8" 45 - otp: "21" 44 + os: ["ubuntu-20.04"] 45 + elixir: ["1.13", "1.12", "1.11"] 46 + otp: ["24", "23", "22"] 46 47 steps: 47 48 - uses: actions/checkout@v2 48 - - uses: erlef/setup-elixir@v1 49 + - uses: erlef/setup-beam@v1 49 50 with: 50 - otp-version: ${{matrix.otp}} 51 - elixir-version: ${{matrix.elixir}} 51 + otp-version: ${{ matrix.otp }} 52 + elixir-version: ${{ matrix.elixir }} 53 + - uses: actions/cache@v2 54 + with: 55 + path: deps 56 + key: ${{ matrix.os }}-otp_${{ matrix.otp }}-elixir_${{ matrix.elixir }}-mix_${{ hashFiles('**/mix.lock') }} 57 + restore-keys: ${{ matrix.os }}-otp_${{ matrix.otp }}-elixir_${{ matrix.elixir }}-mix_ 52 58 - run: mix deps.get --only test 53 59 - run: mix deps.compile 54 60 - run: mix compile
+2
test/support/migration.ex
··· 1 1 defmodule EctoSQLite3.Integration.Migration do 2 + @moduledoc false 3 + 2 4 use Ecto.Migration 3 5 4 6 def change do
+2
test/support/repo.ex
··· 1 1 defmodule Ecto.Integration.TestRepo do 2 + @moduledoc false 3 + 2 4 use Ecto.Repo, otp_app: :ecto_sqlite3, adapter: Ecto.Adapters.SQLite3 3 5 4 6 def create_prefix(_) do
+14 -1
test/support/schemas.ex
··· 1 1 defmodule EctoSQLite3.Integration.Account do 2 + @moduledoc false 3 + 2 4 use Ecto.Schema 3 5 4 6 import Ecto.Changeset 5 7 6 - alias EctoSQLite3.Integration.User 7 8 alias EctoSQLite3.Integration.Product 9 + alias EctoSQLite3.Integration.User 8 10 9 11 schema "accounts" do 10 12 field(:name, :string) ··· 24 26 end 25 27 26 28 defmodule EctoSQLite3.Integration.User do 29 + @moduledoc false 30 + 27 31 use Ecto.Schema 28 32 29 33 import Ecto.Changeset ··· 46 50 end 47 51 48 52 defmodule EctoSQLite3.Integration.AccountUser do 53 + @moduledoc false 54 + 49 55 use Ecto.Schema 50 56 51 57 import Ecto.Changeset ··· 68 74 end 69 75 70 76 defmodule EctoSQLite3.Integration.Product do 77 + @moduledoc false 78 + 71 79 use Ecto.Schema 72 80 73 81 import Ecto.Changeset ··· 104 112 end 105 113 106 114 defmodule EctoSQLite3.Integration.Vec3f do 115 + @moduledoc false 116 + 107 117 use Ecto.Schema 108 118 109 119 schema "vec3f" do ··· 114 124 end 115 125 116 126 defmodule EctoSQLite3.Integration.Setting do 127 + @moduledoc false 128 + 117 129 use Ecto.Schema 130 + 118 131 import Ecto.Changeset 119 132 120 133 schema "settings" do
+9 -7
lib/ecto/adapters/sqlite3.ex
··· 165 165 def storage_down(options) do 166 166 db_path = Keyword.fetch!(options, :database) 167 167 168 - with :ok <- File.rm(db_path) do 169 - File.rm(db_path <> "-shm") 170 - File.rm(db_path <> "-wal") 171 - :ok 172 - else 173 - _ -> {:error, :already_down} 168 + case File.rm(db_path) do 169 + :ok -> 170 + File.rm(db_path <> "-shm") 171 + File.rm(db_path <> "-wal") 172 + :ok 173 + 174 + _otherwise -> 175 + {:error, :already_down} 174 176 end 175 177 end 176 178 ··· 194 196 end 195 197 196 198 @impl Ecto.Adapter.Migration 197 - def supports_ddl_transaction?(), do: false 199 + def supports_ddl_transaction?, do: false 198 200 199 201 @impl Ecto.Adapter.Migration 200 202 def lock_for_migrations(_meta, _options, fun) do
+1 -1
test/ecto/integration/crud_test.exs
··· 3 3 4 4 alias Ecto.Integration.TestRepo 5 5 alias EctoSQLite3.Integration.Account 6 - alias EctoSQLite3.Integration.User 7 6 alias EctoSQLite3.Integration.AccountUser 8 7 alias EctoSQLite3.Integration.Product 8 + alias EctoSQLite3.Integration.User 9 9 10 10 import Ecto.Query 11 11
+3 -2
test/ecto/integration/json_test.exs
··· 1 1 defmodule Ecto.Integration.JsonTest do 2 2 use Ecto.Integration.Case 3 3 4 - alias EctoSQLite3.Integration.Setting 4 + alias Ecto.Adapters.SQL 5 5 alias Ecto.Integration.TestRepo 6 + alias EctoSQLite3.Integration.Setting 6 7 7 8 test "serializes json correctly" do 8 9 # Insert a record purposefully with atoms as the map key. We are going to ··· 17 18 TestRepo.get(Setting, setting.id) 18 19 19 20 assert %{num_rows: 1, rows: [["bar"]]} = 20 - Ecto.Adapters.SQL.query!( 21 + SQL.query!( 21 22 TestRepo, 22 23 "select json_extract(properties, '$.foo') from settings where id = ?1", 23 24 [setting.id]
+6 -10
lib/ecto/adapters/sqlite3/codec.ex
··· 26 26 def decimal_decode(nil), do: {:ok, nil} 27 27 28 28 def decimal_decode(x) when is_float(x) do 29 - try do 30 - {:ok, Decimal.from_float(x)} 31 - catch 32 - Decimal.Error -> :error 33 - end 29 + {:ok, Decimal.from_float(x)} 30 + catch 31 + Decimal.Error -> :error 34 32 end 35 33 36 34 def decimal_decode(x) when is_binary(x) or is_integer(x) do 37 - try do 38 - {:ok, Decimal.new(x)} 39 - catch 40 - Decimal.Error -> :error 41 - end 35 + {:ok, Decimal.new(x)} 36 + catch 37 + Decimal.Error -> :error 42 38 end 43 39 44 40 def decimal_decode(_), do: :error
+3 -2
lib/ecto/adapters/sqlite3/connection.ex
··· 3 3 4 4 @behaviour Ecto.Adapters.SQL.Connection 5 5 6 + alias Ecto.Adapters.SQL 6 7 alias Ecto.Migration.Constraint 7 8 alias Ecto.Migration.Index 8 9 alias Ecto.Migration.Reference ··· 19 20 defp default_opts(opts) do 20 21 opts 21 22 |> Keyword.put_new(:journal_mode, :wal) 22 - |> Keyword.put_new(:cache_size, -64000) 23 + |> Keyword.put_new(:cache_size, -64_000) 23 24 |> Keyword.put_new(:temp_store, :memory) 24 25 |> Keyword.put_new(:pool_size, 5) 25 26 end ··· 320 321 def explain_query(conn, query, params, opts) do 321 322 case query(conn, build_explain_query(query), params, opts) do 322 323 {:ok, %Exqlite.Result{} = result} -> 323 - {:ok, Ecto.Adapters.SQL.format_table(result)} 324 + {:ok, SQL.format_table(result)} 324 325 325 326 error -> 326 327 error
+2 -32
test/ecto/adapters/sqlite3/connection_test.exs
··· 1 1 defmodule Ecto.Adapters.SQLite3.ConnectionTest do 2 2 use ExUnit.Case 3 3 4 - alias Ecto.Adapters.SQLite3.Connection 5 4 alias Ecto.Adapters.SQLite3 6 - # alias Ecto.Migration.Table 5 + alias Ecto.Adapters.SQLite3.Connection 6 + alias Ecto.Migration.Reference 7 7 8 8 import Ecto.Query 9 9 import Ecto.Migration, only: [table: 1, table: 2, index: 2, index: 3, constraint: 3] 10 - alias Ecto.Migration.Reference 11 10 12 11 defmodule Comment do 13 12 use Ecto.Schema ··· 2026 2025 VALUES (?,?) \ 2027 2026 ON CONFLICT ("x","y") DO NOTHING\ 2028 2027 """ 2029 - 2030 - # For :update 2031 - # update = 2032 - # from("schema", update: [set: [z: "foo"]]) 2033 - # |> plan(:update_all) 2034 - # |> all() 2035 - # query = insert(nil, "schema", [:x, :y], [[:x, :y]], {update, [], [:x, :y]}, [:z]) 2036 - # assert query == ~s{INSERT INTO schema (x,y) VALUES (?,?) ON CONFLICT (x,y) DO UPDATE SET z = 'foo'} 2037 - 2038 - # update = 2039 - # from("schema", update: [set: [z: ^"foo"]], where: [w: true]) 2040 - # |> plan(:update_all) 2041 - # |> all() 2042 - # query = insert(nil, "schema", [:x, :y], [[:x, :y]], {update, [], [:x, :y]}, [:z]) 2043 - # assert query = ~s{INSERT INTO schema (x,y) VALUES (?,?) ON CONFLICT (x,y) DO UPDATE SET z = ? WHERE (schema.w = 1)} 2044 - 2045 - # update = 2046 - # from("schema", update: [set: [z: "foo"]]) 2047 - # |> plan(:update_all) 2048 - # |> all() 2049 - # query = insert(nil, "schema", [:x, :y], [[:x, :y]], {update, [], [:x, :y]}, [:z]) 2050 - # assert query = ~s{INSERT INTO schema (x,y) VALUES (?,?) ON CONFLICT (x,y) DO UPDATE SET z = 'foo'} 2051 - 2052 - # update = 2053 - # from("schema", update: [set: [z: ^"foo"]], where: [w: true]) 2054 - # |> plan(:update_all) 2055 - # |> all() 2056 - # query = insert(nil, "schema", [:x, :y], [[:x, :y]], {update, [], [:x, :y]}, [:z]) 2057 - # assert query = ~s{INSERT INTO schema (x,y) VALUES (?,?) ON CONFLICT (x,y) DO UPDATE SET z = ? WHERE (schema.w = 1)} 2058 2028 2059 2029 # For :replace_all 2060 2030 assert_raise(