activerecord-dbt 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +103 -77
  3. data/lib/active_record/dbt/column/{test.rb → data_test.rb} +16 -16
  4. data/lib/active_record/dbt/column/{testable/accepted_values_testable.rb → data_testable/accepted_values_data_testable.rb} +2 -2
  5. data/lib/active_record/dbt/column/{testable/not_null_testable.rb → data_testable/not_null_data_testable.rb} +2 -2
  6. data/lib/active_record/dbt/column/{testable/relationships_testable.rb → data_testable/relationships_data_testable.rb} +3 -3
  7. data/lib/active_record/dbt/column/{testable/unique_testable.rb → data_testable/unique_data_testable.rb} +2 -2
  8. data/lib/active_record/dbt/column/{column.rb → yml.rb} +7 -7
  9. data/lib/active_record/dbt/configuration/i18n_configuration.rb +1 -1
  10. data/lib/active_record/dbt/dbt_package/dbt_utils/table/{testable/unique_combination_of_columns_testable.rb → data_testable/unique_combination_of_columns_data_testable.rb} +2 -2
  11. data/lib/active_record/dbt/dbt_package/dbterd/column/{testable → data_testable}/relationships_meta_relationship_type.rb +2 -2
  12. data/lib/active_record/dbt/factory/columns/yml_factory.rb +33 -0
  13. data/lib/active_record/dbt/factory/model/staging/yml_factory.rb +24 -0
  14. data/lib/active_record/dbt/factory/source/yml_factory.rb +17 -0
  15. data/lib/active_record/dbt/factory/table/yml_factory.rb +18 -0
  16. data/lib/active_record/dbt/factory/tables/yml_factory.rb +17 -0
  17. data/lib/active_record/dbt/model/staging/base.rb +1 -1
  18. data/lib/active_record/dbt/model/staging/yml.rb +5 -5
  19. data/lib/active_record/dbt/seed/enum/base.rb +1 -1
  20. data/lib/active_record/dbt/seed/enum/yml.rb +8 -8
  21. data/lib/active_record/dbt/source/yml.rb +8 -4
  22. data/lib/active_record/dbt/table/{test.rb → data_test.rb} +3 -3
  23. data/lib/active_record/dbt/table/yml.rb +6 -6
  24. data/lib/active_record/dbt/version.rb +1 -1
  25. data/lib/generators/active_record/dbt/config/templates/source_config.yml.tt +2 -2
  26. data/lib/generators/active_record/dbt/enum/USAGE +2 -2
  27. data/lib/generators/active_record/dbt/initializer/templates/dbt.rb +9 -7
  28. data/lib/generators/active_record/dbt/source/USAGE +1 -1
  29. data/lib/generators/active_record/dbt/source/source_generator.rb +3 -4
  30. data/lib/generators/active_record/dbt/staging_model/USAGE +2 -2
  31. data/lib/generators/active_record/dbt/staging_model/staging_model_generator.rb +1 -1
  32. metadata +16 -16
  33. data/lib/active_record/dbt/factory/columns_factory.rb +0 -31
  34. data/lib/active_record/dbt/factory/model/staging_factory.rb +0 -22
  35. data/lib/active_record/dbt/factory/source_factory.rb +0 -15
  36. data/lib/active_record/dbt/factory/table_factory.rb +0 -16
  37. data/lib/active_record/dbt/factory/tables_factory.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: affd8c9f9864d11cbaf5c35a759ea603c72784b9eae777987debad89fd8cd509
4
- data.tar.gz: 6b8ca507c1e413143f3d0a7330451767190b3acb731e70c8b2beb87bff9df64b
3
+ metadata.gz: 723d33af77e2e665a7baa13aeebdc892ebca6fad469622494591752e59ff3a4f
4
+ data.tar.gz: f3ced61ce633c40e8464fd5280f200b062d073f96809fae300de2592c15a10bd
5
5
  SHA512:
6
- metadata.gz: 2798392f8cdcb454a64957a005d7d16e3eeec7e1648234ba5c598cbacb6b683198493337619c9e0a9f17f67a231f6a3fc6f34658651671de3776c7caf28093c9
7
- data.tar.gz: d417dfdd69d8a0c41baee03a41a0880ecba05abbbb61c86b80ed1ef48021bcdda16a4e2b43dd414a29d7f56ad9cf92a0e3afe0a693b5ae4aa3a38e0bbeb9f03d
6
+ metadata.gz: 38293faab98d461a080d9699401ac8c5fb8f59c8f1f19cda3a8ed082fd0ebc8041aaf13a9a1ecf57e484fd3f66c976404cc1c3697f7b97d8c4ae9106f942f165
7
+ data.tar.gz: f966416f03dc58ba525488afac7f13df368607f1b57b3b6c6cf206a5ed56cf7757a52d20fab68f9463f9ab754f72eb622667b42e588abb02aa3a255d4e6c4c32
data/README.md CHANGED
@@ -84,16 +84,18 @@ Adjust the settings according to your environment.
84
84
  ```ruby
85
85
  # frozen_string_literal: true
86
86
 
87
- require 'active_record/dbt'
88
-
89
- ActiveRecord::Dbt.configure do |c|
90
- c.config_directory_path = 'lib/dbt'
91
- c.export_directory_path = 'doc/dbt'
92
- c.data_sync_delayed = false
93
- c.used_dbt_package_names = [
94
- 'dbt-labs/dbt_utils',
95
- 'datnguye/dbterd'
96
- ]
87
+ if Rails.env.development?
88
+ require 'active_record/dbt'
89
+
90
+ ActiveRecord::Dbt.configure do |c|
91
+ c.config_directory_path = 'lib/dbt'
92
+ c.export_directory_path = 'doc/dbt'
93
+ c.data_sync_delayed = false
94
+ c.used_dbt_package_names = [
95
+ 'dbt-labs/dbt_utils',
96
+ 'datnguye/dbterd'
97
+ ]
98
+ end
97
99
  end
98
100
 
99
101
  ```
@@ -110,8 +112,8 @@ This will create the following files.
110
112
 
111
113
  File | Description
112
114
  --------- | ---------
113
- `#{config_directory_path}/source_config.yml` | Used to generate `#{export_directory_path}/src_#{source_name}.yml`.
114
- `#{config_directory_path}/staging_model.sql.tt` | Used to generate `#{export_directory_path}/stg_#{source_name}__#{table_name}.sql`.
115
+ `#{config_directory_path}/source_config.yml` | Used to generate `#{export_directory_path}/models/sources/#{source_name}/src_#{source_name}.yml`.
116
+ `#{config_directory_path}/staging_model.sql.tt` | Used to generate `#{export_directory_path}/models/staging/#{source_name}/stg_#{source_name}__#{table_name}.sql`.
115
117
 
116
118
  ### Generate dbt Source File
117
119
 
@@ -158,7 +160,7 @@ table_overrides:
158
160
  period: day
159
161
  columns:
160
162
  created_at:
161
- tests:
163
+ data_tests:
162
164
  - not_null:
163
165
  where: 'id != 1'
164
166
 
@@ -251,7 +253,7 @@ table_overrides:
251
253
  period: day
252
254
  columns:
253
255
  created_at:
254
- tests:
256
+ data_tests:
255
257
  - not_null:
256
258
  where: 'id != 1'
257
259
 
@@ -282,7 +284,7 @@ table_descriptions:
282
284
 
283
285
  ```
284
286
 
285
- #### Generate `#{export_directory_path}/src_#{source_name}.yml`
287
+ #### Generate `#{export_directory_path}/models/sources/#{source_name}/src_#{source_name}.yml`
286
288
 
287
289
  Generate a source file for dbt:
288
290
 
@@ -290,7 +292,7 @@ Generate a source file for dbt:
290
292
  $ bin/rails generate active_record:dbt:source
291
293
  ```
292
294
 
293
- Generate `#{export_directory_path}/src_#{source_name}.yml`.
295
+ Generate `#{export_directory_path}/models/sources/#{source_name}/src_#{source_name}.yml`.
294
296
 
295
297
  ##### Example:
296
298
 
@@ -298,6 +300,14 @@ Generate `#{export_directory_path}/src_#{source_name}.yml`.
298
300
  >
299
301
  > The output will be as shown below. It is recommended to indent the YAML file with a tool of your choice.
300
302
 
303
+ > [!WARNING]
304
+ >
305
+ > If you are using a version of dbt lower than v1.8, replace `tests:` with `data_tests:` in the generated file.
306
+ >
307
+ > [Add data tests to your DAG | dbt Developer Hub](https://docs.getdbt.com/docs/build/data-tests#new-data_tests-syntax)
308
+ >
309
+ >> Data tests were historically called "tests" in dbt as the only form of testing available. With the introduction of unit tests in v1.8, the key was renamed from `tests:` to `data_tests:`.
310
+
301
311
  ```yaml
302
312
  ---
303
313
  version: 2
@@ -318,7 +328,7 @@ sources:
318
328
  - name: key
319
329
  description: Key
320
330
  data_type: string
321
- tests:
331
+ data_tests:
322
332
  - unique
323
333
  - not_null
324
334
  - name: value
@@ -327,12 +337,12 @@ sources:
327
337
  - name: created_at
328
338
  description: Created At
329
339
  data_type: datetime
330
- tests:
340
+ data_tests:
331
341
  - not_null
332
342
  - name: updated_at
333
343
  description: Updated At
334
344
  data_type: datetime
335
- tests:
345
+ data_tests:
336
346
  - not_null
337
347
  - name: companies
338
348
  description: Write a logical_name of the 'companies' table.
@@ -340,13 +350,13 @@ sources:
340
350
  - name: id
341
351
  description: id
342
352
  data_type: int64
343
- tests:
353
+ data_tests:
344
354
  - unique
345
355
  - not_null
346
356
  - name: name
347
357
  description: Write a description of the 'companies.name' column.
348
358
  data_type: string
349
- tests:
359
+ data_tests:
350
360
  - not_null
351
361
  - name: establishment_date
352
362
  description: Write a description of the 'companies.establishment_date' column.
@@ -357,7 +367,7 @@ sources:
357
367
  - name: published
358
368
  description: Write a description of the 'companies.published' column.
359
369
  data_type: bool
360
- tests:
370
+ data_tests:
361
371
  - not_null
362
372
  - accepted_values:
363
373
  values:
@@ -367,12 +377,12 @@ sources:
367
377
  - name: created_at
368
378
  description: Created At
369
379
  data_type: datetime
370
- tests:
380
+ data_tests:
371
381
  - not_null
372
382
  - name: updated_at
373
383
  description: Updated At
374
384
  data_type: datetime
375
- tests:
385
+ data_tests:
376
386
  - not_null
377
387
  - name: posts
378
388
  description: Post
@@ -380,13 +390,13 @@ sources:
380
390
  - name: id
381
391
  description: ID
382
392
  data_type: int64
383
- tests:
393
+ data_tests:
384
394
  - unique
385
395
  - not_null
386
396
  - name: user_id
387
397
  description: User
388
398
  data_type: int64
389
- tests:
399
+ data_tests:
390
400
  - not_null
391
401
  - relationships:
392
402
  to: source('dummy', 'users')
@@ -402,17 +412,17 @@ sources:
402
412
  - name: created_at
403
413
  description: Post Created At
404
414
  data_type: datetime
405
- tests:
415
+ data_tests:
406
416
  - not_null
407
417
  - name: updated_at
408
418
  description: Post Updated At
409
419
  data_type: datetime
410
- tests:
420
+ data_tests:
411
421
  - not_null
412
422
  - name: status
413
423
  description: Write a description of the 'posts.status' column.
414
424
  data_type: int64
415
- tests:
425
+ data_tests:
416
426
  - accepted_values:
417
427
  values:
418
428
  - 0
@@ -421,7 +431,7 @@ sources:
421
431
  quote: false
422
432
  - name: posts_tags
423
433
  description: Write a logical_name of the 'posts_tags' table.
424
- tests:
434
+ data_tests:
425
435
  - dbt_utils.unique_combination_of_columns:
426
436
  combination_of_columns:
427
437
  - post_id
@@ -430,7 +440,7 @@ sources:
430
440
  - name: post_id
431
441
  description: post_id
432
442
  data_type: int64
433
- tests:
443
+ data_tests:
434
444
  - not_null
435
445
  - relationships:
436
446
  to: source('dummy', 'posts')
@@ -443,7 +453,7 @@ sources:
443
453
  - name: tag_id
444
454
  description: tag_id
445
455
  data_type: int64
446
- tests:
456
+ data_tests:
447
457
  - not_null
448
458
  - relationships:
449
459
  to: source('dummy', 'tags')
@@ -459,13 +469,13 @@ sources:
459
469
  - name: id
460
470
  description: id
461
471
  data_type: int64
462
- tests:
472
+ data_tests:
463
473
  - unique
464
474
  - not_null
465
475
  - name: user_id
466
476
  description: user_id
467
477
  data_type: int64
468
- tests:
478
+ data_tests:
469
479
  - unique
470
480
  - not_null
471
481
  - relationships:
@@ -476,26 +486,26 @@ sources:
476
486
  - name: first_name
477
487
  description: Write a description of the 'profiles.first_name' column.
478
488
  data_type: string
479
- tests:
489
+ data_tests:
480
490
  - not_null
481
491
  - name: last_name
482
492
  description: Write a description of the 'profiles.last_name' column.
483
493
  data_type: string
484
- tests:
494
+ data_tests:
485
495
  - not_null
486
496
  - name: created_at
487
497
  description: Created At
488
498
  data_type: datetime
489
- tests:
499
+ data_tests:
490
500
  - not_null
491
501
  - name: updated_at
492
502
  description: Updated At
493
503
  data_type: datetime
494
- tests:
504
+ data_tests:
495
505
  - not_null
496
506
  - name: relationships
497
507
  description: Write a logical_name of the 'relationships' table.
498
- tests:
508
+ data_tests:
499
509
  - dbt_utils.unique_combination_of_columns:
500
510
  combination_of_columns:
501
511
  - follower_id
@@ -504,13 +514,13 @@ sources:
504
514
  - name: id
505
515
  description: id
506
516
  data_type: int64
507
- tests:
517
+ data_tests:
508
518
  - unique
509
519
  - not_null
510
520
  - name: follower_id
511
521
  description: follower_id
512
522
  data_type: int64
513
- tests:
523
+ data_tests:
514
524
  - not_null
515
525
  - relationships:
516
526
  to: source('dummy', 'users')
@@ -520,7 +530,7 @@ sources:
520
530
  - name: followed_id
521
531
  description: followed_id
522
532
  data_type: int64
523
- tests:
533
+ data_tests:
524
534
  - not_null
525
535
  - relationships:
526
536
  to: source('dummy', 'users')
@@ -530,12 +540,12 @@ sources:
530
540
  - name: created_at
531
541
  description: Created At
532
542
  data_type: datetime
533
- tests:
543
+ data_tests:
534
544
  - not_null
535
545
  - name: updated_at
536
546
  description: Updated At
537
547
  data_type: datetime
538
- tests:
548
+ data_tests:
539
549
  - not_null
540
550
  - name: schema_migrations
541
551
  description: |-
@@ -546,7 +556,7 @@ sources:
546
556
  - name: version
547
557
  description: The version number of the migration.
548
558
  data_type: string
549
- tests:
559
+ data_tests:
550
560
  - unique
551
561
  - not_null
552
562
  - name: tags
@@ -555,28 +565,28 @@ sources:
555
565
  - name: id
556
566
  description: id
557
567
  data_type: int64
558
- tests:
568
+ data_tests:
559
569
  - unique
560
570
  - not_null
561
571
  - name: name
562
572
  description: Write a description of the 'tags.name' column.
563
573
  data_type: string
564
- tests:
574
+ data_tests:
565
575
  - unique
566
576
  - not_null
567
577
  - name: created_at
568
578
  description: Created At
569
579
  data_type: datetime
570
- tests:
580
+ data_tests:
571
581
  - not_null
572
582
  - name: updated_at
573
583
  description: Updated At
574
584
  data_type: datetime
575
- tests:
585
+ data_tests:
576
586
  - not_null
577
587
  - name: user_tags
578
588
  description: Write a logical_name of the 'user_tags' table.
579
- tests:
589
+ data_tests:
580
590
  - dbt_utils.unique_combination_of_columns:
581
591
  combination_of_columns:
582
592
  - user_id
@@ -585,13 +595,13 @@ sources:
585
595
  - name: id
586
596
  description: id
587
597
  data_type: int64
588
- tests:
598
+ data_tests:
589
599
  - unique
590
600
  - not_null
591
601
  - name: user_id
592
602
  description: user_id
593
603
  data_type: int64
594
- tests:
604
+ data_tests:
595
605
  - not_null
596
606
  - relationships:
597
607
  to: source('dummy', 'users')
@@ -601,7 +611,7 @@ sources:
601
611
  - name: tag_id
602
612
  description: tag_id
603
613
  data_type: int64
604
- tests:
614
+ data_tests:
605
615
  - not_null
606
616
  - relationships:
607
617
  to: source('dummy', 'tags')
@@ -611,12 +621,12 @@ sources:
611
621
  - name: created_at
612
622
  description: Created At
613
623
  data_type: datetime
614
- tests:
624
+ data_tests:
615
625
  - not_null
616
626
  - name: updated_at
617
627
  description: Updated At
618
628
  data_type: datetime
619
- tests:
629
+ data_tests:
620
630
  - not_null
621
631
  - name: users
622
632
  description: User
@@ -632,24 +642,24 @@ sources:
632
642
  - name: id
633
643
  description: ID
634
644
  data_type: int64
635
- tests:
645
+ data_tests:
636
646
  - unique
637
647
  - not_null
638
648
  - name: created_at
639
649
  description: User Created At
640
650
  data_type: datetime
641
- tests:
651
+ data_tests:
642
652
  - not_null:
643
653
  where: id != 1
644
654
  - name: updated_at
645
655
  description: User Updated At
646
656
  data_type: datetime
647
- tests:
657
+ data_tests:
648
658
  - not_null
649
659
  - name: company_id
650
660
  description: company_id
651
661
  data_type: int64
652
- tests:
662
+ data_tests:
653
663
  - relationships:
654
664
  to: source('dummy', 'companies')
655
665
  field: id
@@ -748,8 +758,8 @@ Generate staging model files for dbt that reference the specified `TABLE_NAME`.
748
758
 
749
759
  File | Description
750
760
  --------- | ---------
751
- `#{export_directory_path}/stg_#{source_name}__#{table_name}.sql` | Staging model file for dbt.
752
- `#{export_directory_path}/stg_#{source_name}__#{table_name}.yml` | Staging model documentation file for dbt.
761
+ `#{export_directory_path}/models/staging/#{source_name}/stg_#{source_name}__#{table_name}.sql` | Staging model file for dbt.
762
+ `#{export_directory_path}/models/staging/#{source_name}/stg_#{source_name}__#{table_name}.yml` | Staging model documentation file for dbt.
753
763
 
754
764
  Example:
755
765
 
@@ -757,7 +767,7 @@ Example:
757
767
  $ bin/rails generate active_record:dbt:staging_model profiles
758
768
  ```
759
769
 
760
- ##### Generate `#{export_directory_path}/stg_#{source_name}__#{table_name}.sql`
770
+ ##### Generate `#{export_directory_path}/models/staging/#{source_name}/stg_#{source_name}__#{table_name}.sql`
761
771
 
762
772
  Example:
763
773
 
@@ -828,7 +838,7 @@ from final
828
838
 
829
839
  ```
830
840
 
831
- ##### Generate `#{export_directory_path}/stg_#{source_name}__#{table_name}.yml`
841
+ ##### Generate `#{export_directory_path}/models/staging/#{source_name}/stg_#{source_name}__#{table_name}.yml`
832
842
 
833
843
  Example:
834
844
 
@@ -836,6 +846,14 @@ Example:
836
846
  >
837
847
  > The output will be as shown below. It is recommended to indent the YAML file with a tool of your choice.
838
848
 
849
+ > [!WARNING]
850
+ >
851
+ > If you are using a version of dbt lower than v1.8, replace `tests:` with `data_tests:` in the generated file.
852
+ >
853
+ > [Add data tests to your DAG | dbt Developer Hub](https://docs.getdbt.com/docs/build/data-tests#new-data_tests-syntax)
854
+ >
855
+ >> Data tests were historically called "tests" in dbt as the only form of testing available. With the introduction of unit tests in v1.8, the key was renamed from `tests:` to `data_tests:`.
856
+
839
857
  ```yaml
840
858
  ---
841
859
  version: 2
@@ -846,7 +864,7 @@ models:
846
864
  - name: profile_id
847
865
  description: profile_id
848
866
  data_type: int64
849
- tests:
867
+ data_tests:
850
868
  - unique
851
869
  - not_null
852
870
  - relationships:
@@ -857,7 +875,7 @@ models:
857
875
  - name: user_id
858
876
  description: user_id
859
877
  data_type: int64
860
- tests:
878
+ data_tests:
861
879
  - unique
862
880
  - not_null
863
881
  - relationships:
@@ -868,22 +886,22 @@ models:
868
886
  - name: first_name
869
887
  description: Write a description of the 'profiles.first_name' column.
870
888
  data_type: string
871
- tests:
889
+ data_tests:
872
890
  - not_null
873
891
  - name: last_name
874
892
  description: Write a description of the 'profiles.last_name' column.
875
893
  data_type: string
876
- tests:
894
+ data_tests:
877
895
  - not_null
878
896
  - name: created_at
879
897
  description: Created At
880
898
  data_type: datetime
881
- tests:
899
+ data_tests:
882
900
  - not_null
883
901
  - name: updated_at
884
902
  description: Updated At
885
903
  data_type: datetime
886
- tests:
904
+ data_tests:
887
905
  - not_null
888
906
 
889
907
  ```
@@ -933,8 +951,8 @@ Generate seed enum files for dbt from the specified `TABLE_NAME` and `ENUM_COLUM
933
951
 
934
952
  File | Description
935
953
  --------- | ---------
936
- `#{export_directory_path}/seed_#{source_name}__#{table_name_singularize}_enum_#{enum_pluralized}.csv` | Seed enum file for dbt.
937
- `#{export_directory_path}/seed_#{source_name}__#{table_name_singularize}_enum_#{enum_pluralized}.yml` | Seed enum documentation file for dbt.
954
+ `#{export_directory_path}/seeds/#{source_name}/seed_#{source_name}__#{table_name_singularize}_enum_#{enum_pluralized}.csv` | Seed enum file for dbt.
955
+ `#{export_directory_path}/seeds/#{source_name}/seed_#{source_name}__#{table_name_singularize}_enum_#{enum_pluralized}.yml` | Seed enum documentation file for dbt.
938
956
 
939
957
  Example:
940
958
 
@@ -942,7 +960,7 @@ Example:
942
960
  $ bin/rails generate active_record:dbt:enum posts status
943
961
  ```
944
962
 
945
- ##### Generate `#{export_directory_path}/seed_#{source_name}__#{table_name_singularize}_enum_#{enum_pluralized}.csv`
963
+ ##### Generate `#{export_directory_path}/seeds/#{source_name}/seed_#{source_name}__#{table_name_singularize}_enum_#{enum_pluralized}.csv`
946
964
 
947
965
  Example:
948
966
 
@@ -954,7 +972,7 @@ status_before_type_of_cast,status_key,status_en,status_ja
954
972
 
955
973
  ```
956
974
 
957
- ##### Generate `#{export_directory_path}/seed_#{source_name}__#{table_name_singularize}_enum_#{enum_pluralized}.yml`
975
+ ##### Generate `#{export_directory_path}/seeds/#{source_name}/seed_#{source_name}__#{table_name_singularize}_enum_#{enum_pluralized}.yml`
958
976
 
959
977
  Example:
960
978
 
@@ -962,6 +980,14 @@ Example:
962
980
  >
963
981
  > The output will be as shown below. It is recommended to indent the YAML file with a tool of your choice.
964
982
 
983
+ > [!WARNING]
984
+ >
985
+ > If you are using a version of dbt lower than v1.8, replace `tests:` with `data_tests:` in the generated file.
986
+ >
987
+ > [Add data tests to your DAG | dbt Developer Hub](https://docs.getdbt.com/docs/build/data-tests#new-data_tests-syntax)
988
+ >
989
+ >> Data tests were historically called "tests" in dbt as the only form of testing available. With the introduction of unit tests in v1.8, the key was renamed from `tests:` to `data_tests:`.
990
+
965
991
  ```yaml
966
992
  ---
967
993
  version: 2
@@ -977,22 +1003,22 @@ seeds:
977
1003
  columns:
978
1004
  - name: status_before_type_of_cast
979
1005
  description: Status
980
- tests:
1006
+ data_tests:
981
1007
  - unique
982
1008
  - not_null
983
1009
  - name: status_key
984
1010
  description: Status(key)
985
- tests:
1011
+ data_tests:
986
1012
  - unique
987
1013
  - not_null
988
1014
  - name: status_en
989
1015
  description: Status(en)
990
- tests:
1016
+ data_tests:
991
1017
  - unique
992
1018
  - not_null
993
1019
  - name: status_ja
994
1020
  description: Status(ja)
995
- tests:
1021
+ data_tests:
996
1022
  - unique
997
1023
  - not_null
998
1024
 
@@ -3,11 +3,11 @@
3
3
  module ActiveRecord
4
4
  module Dbt
5
5
  module Column
6
- class Test
7
- include ActiveRecord::Dbt::Column::Testable::AcceptedValuesTestable
8
- include ActiveRecord::Dbt::Column::Testable::NotNullTestable
9
- include ActiveRecord::Dbt::Column::Testable::RelationshipsTestable
10
- include ActiveRecord::Dbt::Column::Testable::UniqueTestable
6
+ class DataTest
7
+ include ActiveRecord::Dbt::Column::DataTestable::AcceptedValuesDataTestable
8
+ include ActiveRecord::Dbt::Column::DataTestable::NotNullDataTestable
9
+ include ActiveRecord::Dbt::Column::DataTestable::RelationshipsDataTestable
10
+ include ActiveRecord::Dbt::Column::DataTestable::UniqueDataTestable
11
11
 
12
12
  attr_reader :table_name, :column, :primary_keys, :foreign_keys
13
13
 
@@ -22,15 +22,15 @@ module ActiveRecord
22
22
  @config = ActiveRecord::Dbt::Config.instance
23
23
  end
24
24
 
25
- def config
26
- (tests.keys | tests_overrides_hash.keys).map do |key|
27
- tests_overrides_hash[key] || tests[key]
25
+ def properties
26
+ (data_tests.keys | data_tests_overrides_hash.keys).map do |key|
27
+ data_tests_overrides_hash[key] || data_tests[key]
28
28
  end.presence
29
29
  end
30
30
 
31
31
  private
32
32
 
33
- def tests
33
+ def data_tests
34
34
  {
35
35
  'unique_test' => unique_test,
36
36
  'not_null_test' => not_null_test,
@@ -39,10 +39,10 @@ module ActiveRecord
39
39
  }.compact
40
40
  end
41
41
 
42
- def tests_overrides_hash
43
- @tests_overrides_hash ||=
44
- tests_overrides.index_by do |tests_override|
45
- "#{extract_key(tests_override)}_test"
42
+ def data_tests_overrides_hash
43
+ @data_tests_overrides_hash ||=
44
+ data_tests_overrides.index_by do |data_tests_override|
45
+ "#{extract_key(data_tests_override)}_test"
46
46
  end
47
47
  end
48
48
 
@@ -50,9 +50,9 @@ module ActiveRecord
50
50
  item.is_a?(Hash) ? item.keys.first : item
51
51
  end
52
52
 
53
- def tests_overrides
54
- @tests_overrides ||=
55
- source_config.dig(:table_overrides, table_name, :columns, column_name, :tests) ||
53
+ def data_tests_overrides
54
+ @data_tests_overrides ||=
55
+ source_config.dig(:table_overrides, table_name, :columns, column_name, :data_tests) ||
56
56
  []
57
57
  end
58
58
  end
@@ -3,8 +3,8 @@
3
3
  module ActiveRecord
4
4
  module Dbt
5
5
  module Column
6
- module Testable
7
- module AcceptedValuesTestable
6
+ module DataTestable
7
+ module AcceptedValuesDataTestable
8
8
  extend ActiveRecord::Dbt::RequiredMethods
9
9
 
10
10
  define_required_methods :@config, :column, :table_name, :column_name
@@ -3,8 +3,8 @@
3
3
  module ActiveRecord
4
4
  module Dbt
5
5
  module Column
6
- module Testable
7
- module NotNullTestable
6
+ module DataTestable
7
+ module NotNullDataTestable
8
8
  extend ActiveRecord::Dbt::RequiredMethods
9
9
 
10
10
  define_required_methods :column
@@ -3,9 +3,9 @@
3
3
  module ActiveRecord
4
4
  module Dbt
5
5
  module Column
6
- module Testable
7
- module RelationshipsTestable
8
- include ActiveRecord::Dbt::DbtPackage::Dbterd::Column::Testable::RelationshipsMetaRelationshipType
6
+ module DataTestable
7
+ module RelationshipsDataTestable
8
+ include ActiveRecord::Dbt::DbtPackage::Dbterd::Column::DataTestable::RelationshipsMetaRelationshipType
9
9
 
10
10
  extend ActiveRecord::Dbt::RequiredMethods
11
11
 
@@ -3,8 +3,8 @@
3
3
  module ActiveRecord
4
4
  module Dbt
5
5
  module Column
6
- module Testable
7
- module UniqueTestable
6
+ module DataTestable
7
+ module UniqueDataTestable
8
8
  extend ActiveRecord::Dbt::RequiredMethods
9
9
 
10
10
  define_required_methods :table_name, :column_name, :primary_keys