elasticsearch_record 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d9553144d67b0b52192c1da8165a42ee27feeadfde5b8e6cc186466c52606ce
4
- data.tar.gz: bf7bcb6fd5bbb97d8595066260349f08c0d8a1fa53da3fc3686b6e6e7a9bced5
3
+ metadata.gz: aee5f9a1e1bc853f7e7648313db47e4b3179f85049baebc364cfce80a3e1dbdf
4
+ data.tar.gz: c3c17cd41fcc22930d28fdfdaedc69f5d5832d003e53141a0682942b8bb29496
5
5
  SHA512:
6
- metadata.gz: 709fb46f9e622a0d0eefff1eae49879a72301cd12cb6c92f465d689a7016269aa6f4b1a80773116c6d6c1e22f77ce40d3688ab12ec3757cca514984421fc7d26
7
- data.tar.gz: 8ddc6805b580aabc3ea085cf61446ec498b712280d5bf7ac2899aa1ef8c9fa02478282c3c807749703406d8bc898f9b9154c32d04394eff3aa813ea395a53cf7
6
+ metadata.gz: e81eb876eb78e6133b4c8edc868f1d72fa2d3064d17680c6f0252f05d4c4029e3a6941dc3cd50948fc31ee91da308bb4f899c0744d708c5b4c66873a51985ba7
7
+ data.tar.gz: 5235d1a1e23ccce634d994fc037a6b15ec0471cbc0cb16e35891f61cd01bad39cedc16c390a569b958677dada149825cdb514d59bb6d85465182b583974deeb7
data/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/elasticsearch_record.svg)](https://badge.fury.io/rb/elasticsearch_record)
4
4
 
5
- ActiveRecord functionality for Elasticsearch indexes & documents.
5
+ ActiveRecord adapter for Elasticsearch
6
6
 
7
- _ElasticsearchRecord is a ActiveRecord-fork and provides similar functionality for Elasticsearch._
7
+ _ElasticsearchRecord is a ActiveRecord adapter and provides similar functionality for Elasticsearch._
8
8
 
9
9
  -----
10
10
 
data/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # ElasticsearchRecord - CHANGELOG
2
2
 
3
+ ## [1.0.2] - 2022-11-07
4
+ * [add] ```ActiveRecord::ConnectionAdapters::ElasticsearchAdapter#migrations_paths``` with 'db/migrate_elasticsearch'
5
+ * [fix] to prevent executing 'primary' migrations to elasticsearch (SchemaDumper may still throw error comments)
6
+ * [add] temporary workarounds for scheme & migrations until we support it (so bin/rails db:migrate - tasks will now run again)
7
+
3
8
  ## [1.0.1] - 2022-10-19
4
9
  * [add] ```ActiveRecord::ConnectionAdapters::Elasticsearch::Type::Nested``` class to cast nested values
5
10
  * [add] **properties** to column definition (so they are also searchable by _Relation_ conditions)
@@ -4,6 +4,23 @@ module ActiveRecord
4
4
  module ConnectionAdapters
5
5
  module Elasticsearch
6
6
  module SchemaStatements # :nodoc:
7
+
8
+ # temporary workaround
9
+ # toDo: fixme
10
+ def create_table(*args)
11
+ $stdout.puts "\n>>> 'create_table' elasticsearch is not supported - the following message is insignificant!"
12
+ end
13
+
14
+ # temporary workaround
15
+ # toDo: fixme
16
+ def assume_migrated_upto_version(version)
17
+ $stdout.puts "\n>>> 'assume_migrated_upto_version' elasticsearch is not supported - the following message is insignificant!"
18
+ end
19
+
20
+
21
+
22
+
23
+
7
24
  # Returns the relation names usable to back Active Record models.
8
25
  # For Elasticsearch this means all indices - which also includes system +dot+ '.' indices.
9
26
  # @see ActiveRecord::ConnectionAdapters::SchemaStatements#data_sources
@@ -131,6 +131,22 @@ module ActiveRecord # :nodoc:
131
131
  @prepared_statements = false
132
132
  end
133
133
 
134
+ def migrations_paths # :nodoc:
135
+ @config[:migrations_paths] || ['db/migrate_elasticsearch']
136
+ end
137
+
138
+ # temporary workaround
139
+ # toDo: fixme
140
+ def use_metadata_table? # :nodoc:
141
+ false
142
+ end
143
+
144
+ # temporary workaround
145
+ # toDo: fixme
146
+ def schema_migration # :nodoc:
147
+ @schema_migration ||= ElasticsearchRecord::SchemaMigration
148
+ end
149
+
134
150
  private
135
151
 
136
152
  def type_map
@@ -263,7 +263,8 @@ module Arel # :nodoc: all
263
263
  # empty / nil columns - instead the nil columns do not exist!!!
264
264
  # This is a big mess, because those missing columns are +not+ editable or savable in any way after we initialize the record...
265
265
  # To prevent NOT-accessible attributes, we need to provide the "full-column-definition" to the query.
266
- claim(:columns, o.source.left.instance_variable_get(:@klass).source_column_names)
266
+ resource_klass = o.source.left.instance_variable_get(:@klass)
267
+ claim(:columns, resource_klass.source_column_names) if resource_klass.respond_to?(:source_column_names)
267
268
 
268
269
  # sets the query
269
270
  resolve(o, :visit_Query) if o.queries.present? || o.wheres.present?
@@ -9,7 +9,7 @@ module ElasticsearchRecord
9
9
  module VERSION
10
10
  MAJOR = 1
11
11
  MINOR = 0
12
- TINY = 1
12
+ TINY = 2
13
13
  PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ require 'active_record/schema_migration'
3
+
4
+ module ElasticsearchRecord
5
+ # temporary workaround
6
+ # toDo: fixme
7
+ class SchemaMigration < ActiveRecord::SchemaMigration # :nodoc:
8
+ class << self
9
+ def create_table
10
+ $stdout.puts "\n>>> 'create_table' elasticsearch is not supported - the following message is insignificant!"
11
+ end
12
+
13
+ def drop_table
14
+ $stdout.puts "\n>>> 'drop_table' elasticsearch is not supported - the following message is insignificant!"
15
+ end
16
+
17
+ def normalized_versions
18
+ []
19
+ end
20
+
21
+ def all_versions
22
+ []
23
+ end
24
+
25
+ def table_exists?
26
+ true
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ElasticsearchRecord
4
+ module Tasks
5
+ class ElasticsearchDatabaseTasks
6
+ delegate :connection, :establish_connection, to: ActiveRecord::Base
7
+
8
+ def initialize(db_config)
9
+ @db_config = db_config
10
+ end
11
+
12
+ def create
13
+ #establish_connection(db_config)
14
+ $stdout.puts "\n>>> 'create' elasticsearch is not supported - the following message is insignificant!"
15
+ end
16
+
17
+ def drop
18
+ #establish_connection(db_config)
19
+ $stdout.puts "\n>>> 'drop' elasticsearch is not supported - the following message is insignificant!"
20
+ end
21
+
22
+ def purge
23
+ create
24
+ drop
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :db_config
30
+ end
31
+ end
32
+ end
@@ -27,6 +27,7 @@ module ElasticsearchRecord
27
27
  autoload :Querying
28
28
  autoload :Query
29
29
  autoload :Result
30
+ autoload :SchemaMigration
30
31
  autoload :StatementCache
31
32
  end
32
33
 
@@ -47,6 +48,12 @@ module ElasticsearchRecord
47
48
  autoload :ResultMethods
48
49
  autoload :ValueMethods
49
50
  end
51
+
52
+ module Tasks
53
+ extend ActiveSupport::Autoload
54
+
55
+ autoload :ElasticsearchDatabaseTasks, 'elasticsearch_record/tasks/elasticsearch_database_tasks'
56
+ end
50
57
  end
51
58
 
52
59
  ActiveSupport.on_load(:active_record) do
@@ -57,4 +64,6 @@ ActiveSupport.on_load(:active_record) do
57
64
  require 'elasticsearch_record/patches/arel/select_statement_patch'
58
65
  require 'elasticsearch_record/patches/arel/update_manager_patch'
59
66
  require 'elasticsearch_record/patches/arel/update_statement_patch'
67
+
68
+ ActiveRecord::Tasks::DatabaseTasks.register_task(/elasticsearch/, "ElasticsearchRecord::Tasks::ElasticsearchDatabaseTasks")
60
69
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Gonsior
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-19 00:00:00.000000000 Z
11
+ date: 2022-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '13.0'
83
- description: 'ElasticsearchRecord is a ActiveRecord-fork and provides similar functionality
83
+ description: 'ElasticsearchRecord is a ActiveRecord adapter and provides similar functionality
84
84
  for Elasticsearch.
85
85
 
86
86
  '
@@ -143,7 +143,9 @@ files:
143
143
  - lib/elasticsearch_record/relation/result_methods.rb
144
144
  - lib/elasticsearch_record/relation/value_methods.rb
145
145
  - lib/elasticsearch_record/result.rb
146
+ - lib/elasticsearch_record/schema_migration.rb
146
147
  - lib/elasticsearch_record/statement_cache.rb
148
+ - lib/elasticsearch_record/tasks/elasticsearch_database_tasks.rb
147
149
  - lib/elasticsearch_record/version.rb
148
150
  - sig/elasticsearch_record.rbs
149
151
  homepage: https://github.com/ruby-smart/elasticsearch_record
@@ -172,5 +174,5 @@ requirements: []
172
174
  rubygems_version: 3.3.7
173
175
  signing_key:
174
176
  specification_version: 4
175
- summary: ActiveRecord functionality for Elasticsearch indexes & documents.
177
+ summary: ActiveRecord adapter for Elasticsearch
176
178
  test_files: []