hekireki 0.42.0 → 0.44.0
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.
- package/dist/bin/activerecord.js +1 -1
- package/dist/bin/ajv.js +1 -1
- package/dist/bin/arktype.js +1 -1
- package/dist/bin/atlas.js +1 -1
- package/dist/bin/django.js +1 -1
- package/dist/bin/drizzle.js +1 -1
- package/dist/bin/ecto.js +1 -1
- package/dist/bin/efcore.js +1 -1
- package/dist/bin/effect.js +1 -1
- package/dist/bin/eloquent.js +1 -1
- package/dist/bin/er.js +1 -1
- package/dist/bin/exposed.js +1 -1
- package/dist/bin/gorm.js +1 -1
- package/dist/bin/hekireki.js +1 -1
- package/dist/bin/kysely.js +1 -1
- package/dist/bin/openapi.js +1 -1
- package/dist/bin/pydantic.js +1 -1
- package/dist/bin/sea-orm.js +1 -1
- package/dist/bin/seed.js +1 -1
- package/dist/bin/sqlalchemy.js +1 -1
- package/dist/bin/typebox.js +1 -1
- package/dist/bin/valibot.js +1 -1
- package/dist/bin/zod.js +1 -1
- package/dist/{bin-CW-vHdsl.js → bin-CVmSO6Yb.js} +356 -46
- package/package.json +1 -1
package/dist/bin/activerecord.js
CHANGED
package/dist/bin/ajv.js
CHANGED
package/dist/bin/arktype.js
CHANGED
package/dist/bin/atlas.js
CHANGED
package/dist/bin/django.js
CHANGED
package/dist/bin/drizzle.js
CHANGED
package/dist/bin/ecto.js
CHANGED
package/dist/bin/efcore.js
CHANGED
package/dist/bin/effect.js
CHANGED
package/dist/bin/eloquent.js
CHANGED
package/dist/bin/er.js
CHANGED
package/dist/bin/exposed.js
CHANGED
package/dist/bin/gorm.js
CHANGED
package/dist/bin/hekireki.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Console, Data, Effect, Schema } from "effect";
|
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { CliError, Command, Flag } from "effect/cli";
|
|
8
8
|
// package.json
|
|
9
|
-
var version = "0.
|
|
9
|
+
var version = "0.44.0";
|
|
10
10
|
// src/schema/path.ts
|
|
11
11
|
/** Where Prisma looks for a schema when neither the command nor prisma.config.ts names one. */
|
|
12
12
|
const DEFAULT_SCHEMA_PATHS = ["prisma/schema.prisma", "schema.prisma"];
|
package/dist/bin/kysely.js
CHANGED
package/dist/bin/openapi.js
CHANGED
package/dist/bin/pydantic.js
CHANGED
package/dist/bin/sea-orm.js
CHANGED
package/dist/bin/seed.js
CHANGED
package/dist/bin/sqlalchemy.js
CHANGED
package/dist/bin/typebox.js
CHANGED
package/dist/bin/valibot.js
CHANGED
package/dist/bin/zod.js
CHANGED
|
@@ -270,6 +270,7 @@ const RUBY_TOP_LEVEL_CONSTANTS = new Set(`
|
|
|
270
270
|
const RAILS_RESERVED_NAMES = new Set(`abort
|
|
271
271
|
abstract_class
|
|
272
272
|
accepts_nested_attributes_for
|
|
273
|
+
act_on_ignored_order
|
|
273
274
|
acts_like
|
|
274
275
|
adapter_class
|
|
275
276
|
add_autosave_association_callbacks
|
|
@@ -288,10 +289,12 @@ after_touch
|
|
|
288
289
|
after_update
|
|
289
290
|
after_update_commit
|
|
290
291
|
after_validation
|
|
292
|
+
aggregate_column
|
|
291
293
|
aggregate_reflections
|
|
292
294
|
alias_attribute
|
|
293
295
|
alias_attribute_method_definition
|
|
294
296
|
alias_method
|
|
297
|
+
alias_tracker
|
|
295
298
|
aliases_by_attribute_name
|
|
296
299
|
all
|
|
297
300
|
all_timestamp_attributes_in_model
|
|
@@ -300,9 +303,20 @@ allow_destroy
|
|
|
300
303
|
ancestors
|
|
301
304
|
and
|
|
302
305
|
annotate
|
|
306
|
+
annotate_values
|
|
303
307
|
append_to_connected_to_stack
|
|
308
|
+
apply_finish_limit
|
|
309
|
+
apply_join_dependency
|
|
310
|
+
apply_limits
|
|
304
311
|
apply_pending_attribute_modifications
|
|
305
312
|
apply_scoping
|
|
313
|
+
apply_start_limit
|
|
314
|
+
arel
|
|
315
|
+
arel_column
|
|
316
|
+
arel_column_aliases_from_hash
|
|
317
|
+
arel_column_with_table
|
|
318
|
+
arel_columns
|
|
319
|
+
arel_columns_from_hash
|
|
306
320
|
arel_table
|
|
307
321
|
around_create
|
|
308
322
|
around_destroy
|
|
@@ -315,6 +329,7 @@ assert_valid_transaction_action
|
|
|
315
329
|
association_cached
|
|
316
330
|
association_foreign_key_changed
|
|
317
331
|
association_valid
|
|
332
|
+
async
|
|
318
333
|
async_average
|
|
319
334
|
async_count
|
|
320
335
|
async_count_by_sql
|
|
@@ -366,6 +381,9 @@ automatically_invert_plural_associations
|
|
|
366
381
|
autosaving_belongs_to_for
|
|
367
382
|
average
|
|
368
383
|
base_class
|
|
384
|
+
batch_condition
|
|
385
|
+
batch_on_loaded_relation
|
|
386
|
+
batch_on_unloaded_relation
|
|
369
387
|
becomes
|
|
370
388
|
before_commit
|
|
371
389
|
before_committed
|
|
@@ -377,17 +395,41 @@ before_validation
|
|
|
377
395
|
belongs_to
|
|
378
396
|
belongs_to_required_by_default
|
|
379
397
|
benchmark
|
|
398
|
+
bind_attribute
|
|
380
399
|
binding
|
|
381
400
|
blank
|
|
382
401
|
block_given
|
|
383
402
|
build
|
|
403
|
+
build_arel
|
|
404
|
+
build_batch_orders
|
|
405
|
+
build_bound_sql_literal
|
|
406
|
+
build_case_for_value_position
|
|
407
|
+
build_cast_value
|
|
384
408
|
build_column_serializer
|
|
409
|
+
build_count_subquery
|
|
385
410
|
build_default_constraint
|
|
386
411
|
build_default_scope
|
|
387
412
|
build_explain_clause
|
|
413
|
+
build_from
|
|
414
|
+
build_having_clause
|
|
415
|
+
build_join_buckets
|
|
416
|
+
build_join_dependencies
|
|
417
|
+
build_joins
|
|
388
418
|
build_mangled_name
|
|
419
|
+
build_named_bound_sql_literal
|
|
420
|
+
build_order
|
|
421
|
+
build_select
|
|
422
|
+
build_subquery
|
|
423
|
+
build_where_clause
|
|
424
|
+
build_with
|
|
425
|
+
build_with_expression_from_value
|
|
426
|
+
build_with_join_node
|
|
427
|
+
build_with_value_from_hash
|
|
389
428
|
cache
|
|
429
|
+
cache_key
|
|
430
|
+
cache_key_with_version
|
|
390
431
|
cache_timestamp_format
|
|
432
|
+
cache_version
|
|
391
433
|
cache_versioning
|
|
392
434
|
cached_find_by
|
|
393
435
|
cached_find_by_statement
|
|
@@ -399,10 +441,13 @@ catch
|
|
|
399
441
|
cattr_accessor
|
|
400
442
|
cattr_reader
|
|
401
443
|
cattr_writer
|
|
444
|
+
chain
|
|
402
445
|
changed
|
|
403
446
|
changed_for_autosave
|
|
404
447
|
check_model_columns
|
|
405
448
|
check_record_limit
|
|
449
|
+
chunk
|
|
450
|
+
chunk_while
|
|
406
451
|
class
|
|
407
452
|
class_attribute
|
|
408
453
|
class_eval
|
|
@@ -413,18 +458,26 @@ class_variables
|
|
|
413
458
|
clear_query_caches_for_current_thread
|
|
414
459
|
clear_reflections_cache
|
|
415
460
|
clone
|
|
461
|
+
collect
|
|
462
|
+
collect_concat
|
|
416
463
|
collecting_queries_for_explain
|
|
417
464
|
collection_cache_key
|
|
418
465
|
collection_cache_versioning
|
|
419
466
|
column_defaults
|
|
420
467
|
column_for_attribute
|
|
421
468
|
column_names
|
|
469
|
+
column_references
|
|
422
470
|
columns
|
|
423
471
|
columns_hash
|
|
424
472
|
combine_signed_id_purposes
|
|
425
473
|
committed
|
|
474
|
+
compact
|
|
475
|
+
compact_blank
|
|
476
|
+
compare_values_for_order
|
|
426
477
|
composed_of
|
|
427
478
|
composite_query_constraints_list
|
|
479
|
+
compute_cache_key
|
|
480
|
+
compute_cache_version
|
|
428
481
|
compute_table_name
|
|
429
482
|
compute_type
|
|
430
483
|
concern
|
|
@@ -449,6 +502,8 @@ const_missing
|
|
|
449
502
|
const_set
|
|
450
503
|
const_source_location
|
|
451
504
|
constants
|
|
505
|
+
construct_join_dependency
|
|
506
|
+
construct_relation_for_exists
|
|
452
507
|
content_columns
|
|
453
508
|
count
|
|
454
509
|
count_by_sql
|
|
@@ -456,14 +511,17 @@ counter_cached_association_names
|
|
|
456
511
|
create
|
|
457
512
|
create_or_find_by
|
|
458
513
|
create_with
|
|
514
|
+
create_with_value
|
|
459
515
|
current_preventing_writes
|
|
460
516
|
current_role
|
|
461
517
|
current_scope
|
|
518
|
+
current_scope_restoring_block
|
|
462
519
|
current_shard
|
|
463
520
|
current_time_from_proper_timezone
|
|
464
521
|
current_transaction
|
|
465
522
|
custom_inspect_method_defined
|
|
466
523
|
custom_validation_context
|
|
524
|
+
cycle
|
|
467
525
|
decorate_attributes
|
|
468
526
|
decrement
|
|
469
527
|
decrement_counter
|
|
@@ -508,18 +566,32 @@ destroy_association_async_batch_size
|
|
|
508
566
|
destroy_association_async_job
|
|
509
567
|
destroy_by
|
|
510
568
|
destroyed
|
|
569
|
+
detect
|
|
511
570
|
deterministic_encrypted_attributes
|
|
512
571
|
discriminate_class_for_record
|
|
513
572
|
display
|
|
514
573
|
distinct
|
|
574
|
+
distinct_value
|
|
575
|
+
drop
|
|
576
|
+
drop_while
|
|
515
577
|
dup
|
|
516
578
|
duplicable
|
|
579
|
+
each
|
|
580
|
+
each_cons
|
|
581
|
+
each_entry
|
|
582
|
+
each_join_dependencies
|
|
583
|
+
each_slice
|
|
584
|
+
each_with_index
|
|
585
|
+
each_with_object
|
|
517
586
|
eager_load
|
|
587
|
+
eager_load_values
|
|
518
588
|
eagerly_generate_alias_attribute_methods
|
|
589
|
+
encode_with
|
|
519
590
|
encrypt_attribute
|
|
520
591
|
encrypted_attribute
|
|
521
592
|
encrypted_attributes
|
|
522
593
|
encrypts
|
|
594
|
+
entries
|
|
523
595
|
enum
|
|
524
596
|
enum_for
|
|
525
597
|
enumerate_columns_in_select_statements
|
|
@@ -532,35 +604,60 @@ except
|
|
|
532
604
|
excluding
|
|
533
605
|
exec
|
|
534
606
|
exec_explain
|
|
607
|
+
exec_main_query
|
|
608
|
+
exec_queries
|
|
609
|
+
execute_grouped_calculation
|
|
610
|
+
execute_simple_calculation
|
|
535
611
|
exit
|
|
612
|
+
explain
|
|
536
613
|
extend
|
|
537
614
|
extended
|
|
538
615
|
extending
|
|
616
|
+
extending_values
|
|
617
|
+
extensions
|
|
539
618
|
extract_associated
|
|
619
|
+
extract_table_name_from
|
|
540
620
|
fail
|
|
541
621
|
false
|
|
542
622
|
fifth
|
|
623
|
+
filter
|
|
543
624
|
filter_attributes
|
|
625
|
+
filter_map
|
|
544
626
|
find
|
|
627
|
+
find_all
|
|
545
628
|
find_by
|
|
546
629
|
find_by_sql
|
|
547
630
|
find_by_token_for
|
|
548
631
|
find_each
|
|
549
632
|
find_in_batches
|
|
633
|
+
find_index
|
|
634
|
+
find_last
|
|
635
|
+
find_nth
|
|
636
|
+
find_nth_from_last
|
|
637
|
+
find_nth_with_limit
|
|
638
|
+
find_one
|
|
550
639
|
find_or_create_by
|
|
551
640
|
find_or_initialize_by
|
|
552
641
|
find_signed
|
|
553
642
|
find_sole_by
|
|
643
|
+
find_some
|
|
644
|
+
find_some_ordered
|
|
554
645
|
find_sti_class
|
|
646
|
+
find_take
|
|
647
|
+
find_take_with_limit
|
|
648
|
+
find_with_ids
|
|
555
649
|
first
|
|
556
650
|
first_or_create
|
|
557
651
|
first_or_initialize
|
|
652
|
+
flat_map
|
|
653
|
+
flattened_args
|
|
558
654
|
fork
|
|
559
655
|
format
|
|
560
656
|
forty_two
|
|
561
657
|
fourth
|
|
562
658
|
freeze
|
|
563
659
|
from
|
|
660
|
+
from_clause
|
|
564
661
|
frozen
|
|
565
662
|
full_table_name_prefix
|
|
566
663
|
full_table_name_suffix
|
|
@@ -582,7 +679,11 @@ gets
|
|
|
582
679
|
global_current_scope
|
|
583
680
|
global_previous_schemes_for
|
|
584
681
|
global_variables
|
|
682
|
+
grep
|
|
683
|
+
grep_v
|
|
585
684
|
group
|
|
685
|
+
group_by
|
|
686
|
+
group_values
|
|
586
687
|
has_and_belongs_to_many
|
|
587
688
|
has_attribute
|
|
588
689
|
has_changes_to_save
|
|
@@ -597,6 +698,7 @@ has_secure_token
|
|
|
597
698
|
has_transactional_callbacks
|
|
598
699
|
hash
|
|
599
700
|
having
|
|
701
|
+
having_clause
|
|
600
702
|
hook_attribute_type
|
|
601
703
|
human_attribute_name
|
|
602
704
|
i18n_scope
|
|
@@ -607,6 +709,8 @@ immutable_strings_by_default
|
|
|
607
709
|
implicit_order_column
|
|
608
710
|
in
|
|
609
711
|
in_batches
|
|
712
|
+
in_groups
|
|
713
|
+
in_groups_of
|
|
610
714
|
in_order_of
|
|
611
715
|
include
|
|
612
716
|
include_relation_methods
|
|
@@ -614,8 +718,13 @@ include_root_in_json
|
|
|
614
718
|
included
|
|
615
719
|
included_modules
|
|
616
720
|
includes
|
|
721
|
+
includes_values
|
|
722
|
+
including
|
|
617
723
|
increment
|
|
618
724
|
increment_counter
|
|
725
|
+
index
|
|
726
|
+
index_by
|
|
727
|
+
index_with
|
|
619
728
|
inheritance_column
|
|
620
729
|
inherited
|
|
621
730
|
initialize
|
|
@@ -626,6 +735,7 @@ initialize_find_by_cache
|
|
|
626
735
|
initialize_generated_modules
|
|
627
736
|
initialize_load_schema_monitor
|
|
628
737
|
initialize_relation_delegate_cache
|
|
738
|
+
inject
|
|
629
739
|
insert
|
|
630
740
|
insert_all
|
|
631
741
|
inspect
|
|
@@ -644,6 +754,7 @@ instance_variables
|
|
|
644
754
|
instance_variables_to_inspect
|
|
645
755
|
instantiate
|
|
646
756
|
instantiate_instance_of
|
|
757
|
+
instantiate_records
|
|
647
758
|
internal_metadata_table_name
|
|
648
759
|
invalid
|
|
649
760
|
inverse_polymorphic_association_changed
|
|
@@ -653,29 +764,47 @@ iterator
|
|
|
653
764
|
itself
|
|
654
765
|
j
|
|
655
766
|
jj
|
|
767
|
+
join
|
|
768
|
+
joined_includes_values
|
|
656
769
|
joins
|
|
770
|
+
joins_values
|
|
657
771
|
kind_of
|
|
772
|
+
klass
|
|
658
773
|
lambda
|
|
659
774
|
last
|
|
775
|
+
lazy
|
|
660
776
|
lease_connection
|
|
661
777
|
left_joins
|
|
662
778
|
left_outer_joins
|
|
779
|
+
left_outer_joins_values
|
|
780
|
+
length
|
|
663
781
|
limit
|
|
782
|
+
limit_value
|
|
783
|
+
limited_count
|
|
664
784
|
load
|
|
785
|
+
load_async
|
|
786
|
+
load_records
|
|
665
787
|
load_schema
|
|
788
|
+
loaded
|
|
666
789
|
local_stored_attributes
|
|
667
790
|
local_variables
|
|
668
791
|
lock
|
|
669
792
|
lock_optimistically
|
|
793
|
+
lock_value
|
|
670
794
|
locking_column
|
|
671
795
|
locking_enabled
|
|
672
796
|
logger
|
|
673
797
|
lookup_ancestors
|
|
798
|
+
lookup_cast_type_from_join_dependencies
|
|
799
|
+
lookup_table_klass_from_join_dependencies
|
|
674
800
|
loop
|
|
801
|
+
map
|
|
675
802
|
marked_for_destruction
|
|
676
803
|
mattr_accessor
|
|
677
804
|
mattr_reader
|
|
678
805
|
mattr_writer
|
|
806
|
+
max
|
|
807
|
+
max_by
|
|
679
808
|
maximum
|
|
680
809
|
merge
|
|
681
810
|
method
|
|
@@ -685,7 +814,12 @@ method_removed
|
|
|
685
814
|
method_undefined
|
|
686
815
|
method_visibility
|
|
687
816
|
methods
|
|
817
|
+
min
|
|
818
|
+
min_by
|
|
688
819
|
minimum
|
|
820
|
+
minmax
|
|
821
|
+
minmax_by
|
|
822
|
+
model
|
|
689
823
|
model_name
|
|
690
824
|
module_eval
|
|
691
825
|
module_exec
|
|
@@ -709,18 +843,26 @@ normalized_reflections
|
|
|
709
843
|
normalizes
|
|
710
844
|
object_id
|
|
711
845
|
offset
|
|
846
|
+
offset_value
|
|
712
847
|
only
|
|
713
848
|
only_columns
|
|
714
849
|
open
|
|
850
|
+
operation_over_aggregate_column
|
|
715
851
|
optimizer_hints
|
|
852
|
+
optimizer_hints_values
|
|
716
853
|
or
|
|
717
854
|
order
|
|
855
|
+
order_column
|
|
856
|
+
order_values
|
|
857
|
+
ordered_relation
|
|
718
858
|
override_accessors_to_preserve_original
|
|
719
859
|
p
|
|
720
860
|
param_delimiter
|
|
721
861
|
partial_inserts
|
|
722
862
|
partial_updates
|
|
863
|
+
partition
|
|
723
864
|
pending_attribute_modifications
|
|
865
|
+
perform_calculation
|
|
724
866
|
persisted
|
|
725
867
|
pick
|
|
726
868
|
pk_attribute
|
|
@@ -733,13 +875,17 @@ pp
|
|
|
733
875
|
predicate_builder
|
|
734
876
|
predicate_for_validation_context
|
|
735
877
|
preload
|
|
878
|
+
preload_associations
|
|
879
|
+
preload_values
|
|
736
880
|
prepend
|
|
737
881
|
prepend_option
|
|
738
882
|
prepended
|
|
883
|
+
preprocess_order_args
|
|
739
884
|
presence
|
|
740
885
|
presence_in
|
|
741
886
|
present
|
|
742
887
|
preserve_original_encrypted
|
|
888
|
+
pretty_print
|
|
743
889
|
previously_new_record
|
|
744
890
|
previously_persisted
|
|
745
891
|
primary_abstract_class
|
|
@@ -754,6 +900,8 @@ private_constant
|
|
|
754
900
|
private_instance_methods
|
|
755
901
|
private_methods
|
|
756
902
|
proc
|
|
903
|
+
process_select_args
|
|
904
|
+
process_with_args
|
|
757
905
|
prohibit_shard_swapping
|
|
758
906
|
protected
|
|
759
907
|
protected_environments
|
|
@@ -784,10 +932,15 @@ readline
|
|
|
784
932
|
readlines
|
|
785
933
|
readonly
|
|
786
934
|
readonly_attributes
|
|
935
|
+
readonly_value
|
|
936
|
+
record_cursor_values
|
|
787
937
|
record_timestamps
|
|
938
|
+
records
|
|
788
939
|
redefine_method
|
|
789
940
|
redefine_singleton_method
|
|
941
|
+
reduce
|
|
790
942
|
references
|
|
943
|
+
references_values
|
|
791
944
|
refinements
|
|
792
945
|
reflect_on_aggregation
|
|
793
946
|
reflect_on_all_aggregations
|
|
@@ -796,10 +949,13 @@ reflect_on_all_autosave_associations
|
|
|
796
949
|
reflect_on_association
|
|
797
950
|
reflections
|
|
798
951
|
regroup
|
|
952
|
+
reject
|
|
799
953
|
reject_new_record
|
|
800
954
|
relation
|
|
801
955
|
relation_delegate_class
|
|
956
|
+
relation_with
|
|
802
957
|
release_connection
|
|
958
|
+
reload
|
|
803
959
|
reload_schema_from_cache
|
|
804
960
|
remove_class_variable
|
|
805
961
|
remove_connection
|
|
@@ -810,6 +966,7 @@ remove_possible_method
|
|
|
810
966
|
remove_possible_singleton_method
|
|
811
967
|
render_bind
|
|
812
968
|
reorder
|
|
969
|
+
reordering_value
|
|
813
970
|
replace_bind_variable
|
|
814
971
|
replace_bind_variables
|
|
815
972
|
replace_named_bind_variables
|
|
@@ -817,6 +974,7 @@ require
|
|
|
817
974
|
require_dependency
|
|
818
975
|
require_relative
|
|
819
976
|
reselect
|
|
977
|
+
reset
|
|
820
978
|
reset_callbacks
|
|
821
979
|
reset_column_information
|
|
822
980
|
reset_counters
|
|
@@ -825,6 +983,7 @@ reset_locking_column
|
|
|
825
983
|
reset_primary_key
|
|
826
984
|
reset_sequence_name
|
|
827
985
|
reset_table_name
|
|
986
|
+
resolve_arel_attributes
|
|
828
987
|
resolve_attribute_name
|
|
829
988
|
resolve_config_for_connection
|
|
830
989
|
resolve_type_name
|
|
@@ -833,11 +992,22 @@ respond_to_missing
|
|
|
833
992
|
respond_to_without_attributes
|
|
834
993
|
restore_attribute
|
|
835
994
|
retrieve_connection
|
|
995
|
+
reverse
|
|
996
|
+
reverse_each
|
|
997
|
+
reverse_order
|
|
998
|
+
reverse_order_value
|
|
999
|
+
reverse_sql_order
|
|
836
1000
|
rewhere
|
|
1001
|
+
rindex
|
|
837
1002
|
rolledback
|
|
1003
|
+
rotate
|
|
838
1004
|
ruby2_keywords
|
|
839
1005
|
run_commit_callbacks_on_first_saved_instances_in_transaction
|
|
840
1006
|
run_validations
|
|
1007
|
+
sample
|
|
1008
|
+
sanitize_for_mass_assignment
|
|
1009
|
+
sanitize_forbidden_attributes
|
|
1010
|
+
sanitize_order_arguments
|
|
841
1011
|
sanitize_sql
|
|
842
1012
|
sanitize_sql_array
|
|
843
1013
|
sanitize_sql_for_assignment
|
|
@@ -854,10 +1024,16 @@ scheme_for
|
|
|
854
1024
|
scope
|
|
855
1025
|
scope_attributes
|
|
856
1026
|
scope_for_association
|
|
1027
|
+
scope_for_create
|
|
857
1028
|
scope_registry
|
|
1029
|
+
scoping
|
|
858
1030
|
second
|
|
859
1031
|
second_to_last
|
|
860
1032
|
select
|
|
1033
|
+
select_association_list
|
|
1034
|
+
select_for_count
|
|
1035
|
+
select_named_joins
|
|
1036
|
+
select_values
|
|
861
1037
|
self
|
|
862
1038
|
send
|
|
863
1039
|
sequence_name
|
|
@@ -871,6 +1047,7 @@ set_trace_func
|
|
|
871
1047
|
shard_keys
|
|
872
1048
|
shard_selector
|
|
873
1049
|
should_record_timestamps
|
|
1050
|
+
shuffle
|
|
874
1051
|
signed_id_verifier
|
|
875
1052
|
signed_id_verifier_secret
|
|
876
1053
|
silence_redefinition_of_method
|
|
@@ -880,12 +1057,23 @@ singleton_method_added
|
|
|
880
1057
|
singleton_method_removed
|
|
881
1058
|
singleton_method_undefined
|
|
882
1059
|
singleton_methods
|
|
1060
|
+
size
|
|
883
1061
|
skip_callback
|
|
1062
|
+
skip_preloading_value
|
|
1063
|
+
skip_query_cache_if_necessary
|
|
1064
|
+
skip_query_cache_value
|
|
884
1065
|
skip_time_zone_conversion_for_attributes
|
|
885
1066
|
sleep
|
|
1067
|
+
slice
|
|
1068
|
+
slice_after
|
|
1069
|
+
slice_before
|
|
1070
|
+
slice_when
|
|
886
1071
|
sole
|
|
1072
|
+
sort
|
|
1073
|
+
sort_by
|
|
887
1074
|
source_attribute_from_preserved_attribute
|
|
888
1075
|
spawn
|
|
1076
|
+
split
|
|
889
1077
|
sprintf
|
|
890
1078
|
srand
|
|
891
1079
|
sti_class_for
|
|
@@ -900,6 +1088,8 @@ strict_loading_all
|
|
|
900
1088
|
strict_loading_by_default
|
|
901
1089
|
strict_loading_mode
|
|
902
1090
|
strict_loading_n_plus_one_only
|
|
1091
|
+
strict_loading_value
|
|
1092
|
+
structurally_incompatible_values_for
|
|
903
1093
|
subclass_from_attributes
|
|
904
1094
|
subclasses
|
|
905
1095
|
sum
|
|
@@ -908,10 +1098,14 @@ suppress
|
|
|
908
1098
|
symbol_column_to_string
|
|
909
1099
|
syscall
|
|
910
1100
|
system
|
|
1101
|
+
table
|
|
911
1102
|
table_name
|
|
912
1103
|
table_name_prefix
|
|
913
1104
|
table_name_suffix
|
|
1105
|
+
tables_in_string
|
|
914
1106
|
take
|
|
1107
|
+
take_while
|
|
1108
|
+
tally
|
|
915
1109
|
tap
|
|
916
1110
|
test
|
|
917
1111
|
then
|
|
@@ -930,11 +1124,20 @@ timestamp_attributes_for_create
|
|
|
930
1124
|
timestamp_attributes_for_create_in_model
|
|
931
1125
|
timestamp_attributes_for_update
|
|
932
1126
|
timestamp_attributes_for_update_in_model
|
|
1127
|
+
to_a
|
|
1128
|
+
to_ary
|
|
933
1129
|
to_enum
|
|
1130
|
+
to_formatted_s
|
|
1131
|
+
to_fs
|
|
1132
|
+
to_h
|
|
934
1133
|
to_json
|
|
935
1134
|
to_param
|
|
936
1135
|
to_query
|
|
937
1136
|
to_s
|
|
1137
|
+
to_sentence
|
|
1138
|
+
to_set
|
|
1139
|
+
to_sql
|
|
1140
|
+
to_xml
|
|
938
1141
|
to_yaml
|
|
939
1142
|
toggle
|
|
940
1143
|
token_definitions
|
|
@@ -947,8 +1150,11 @@ trap
|
|
|
947
1150
|
trigger_transactional_callbacks
|
|
948
1151
|
true
|
|
949
1152
|
try
|
|
1153
|
+
type_cast_calculated_value
|
|
1154
|
+
type_cast_pluck_values
|
|
950
1155
|
type_caster
|
|
951
1156
|
type_condition
|
|
1157
|
+
type_for
|
|
952
1158
|
type_for_attribute
|
|
953
1159
|
type_for_column
|
|
954
1160
|
uncached
|
|
@@ -956,7 +1162,9 @@ undecorated_table_name
|
|
|
956
1162
|
undef_method
|
|
957
1163
|
undefine_attribute_methods
|
|
958
1164
|
undefined_instance_methods
|
|
1165
|
+
uniq
|
|
959
1166
|
unscope
|
|
1167
|
+
unscope_values
|
|
960
1168
|
unscoped
|
|
961
1169
|
untrace_var
|
|
962
1170
|
update
|
|
@@ -969,6 +1177,7 @@ using
|
|
|
969
1177
|
valid
|
|
970
1178
|
validate
|
|
971
1179
|
validate_column_size
|
|
1180
|
+
validate_order_args
|
|
972
1181
|
validates
|
|
973
1182
|
validates_absence_of
|
|
974
1183
|
validates_acceptance_of
|
|
@@ -988,8 +1197,12 @@ validates_with
|
|
|
988
1197
|
validating_belongs_to_for
|
|
989
1198
|
validators
|
|
990
1199
|
validators_on
|
|
1200
|
+
values
|
|
1201
|
+
values_for_queries
|
|
991
1202
|
warn
|
|
992
1203
|
where
|
|
1204
|
+
where_clause
|
|
1205
|
+
where_values_hash
|
|
993
1206
|
while_preventing_writes
|
|
994
1207
|
will_be_destroyed
|
|
995
1208
|
will_save_change_to_attribute
|
|
@@ -998,11 +1211,13 @@ with_connection
|
|
|
998
1211
|
with_pool_transaction_isolation_level
|
|
999
1212
|
with_recursive
|
|
1000
1213
|
with_role_and_shard
|
|
1214
|
+
with_values
|
|
1001
1215
|
without
|
|
1002
1216
|
writer_method
|
|
1003
1217
|
yaml_encoder
|
|
1004
1218
|
yaml_tag
|
|
1005
|
-
yield_self
|
|
1219
|
+
yield_self
|
|
1220
|
+
zip`.split("\n"));
|
|
1006
1221
|
/**
|
|
1007
1222
|
* The class each model is written as: its name in PascalCase, or where Ruby or Rails already has
|
|
1008
1223
|
* a constant of that name at the top level, that name with `Record` after it (`Monitor` is
|
|
@@ -2721,8 +2936,57 @@ const CHOICES_RESERVED = /* @__PURE__ */ new Set([
|
|
|
2721
2936
|
"names",
|
|
2722
2937
|
"mro"
|
|
2723
2938
|
]);
|
|
2939
|
+
const STR_METHODS = /* @__PURE__ */ new Set([
|
|
2940
|
+
"capitalize",
|
|
2941
|
+
"casefold",
|
|
2942
|
+
"center",
|
|
2943
|
+
"count",
|
|
2944
|
+
"encode",
|
|
2945
|
+
"endswith",
|
|
2946
|
+
"expandtabs",
|
|
2947
|
+
"find",
|
|
2948
|
+
"format",
|
|
2949
|
+
"format_map",
|
|
2950
|
+
"index",
|
|
2951
|
+
"isalnum",
|
|
2952
|
+
"isalpha",
|
|
2953
|
+
"isascii",
|
|
2954
|
+
"isdecimal",
|
|
2955
|
+
"isdigit",
|
|
2956
|
+
"isidentifier",
|
|
2957
|
+
"islower",
|
|
2958
|
+
"isnumeric",
|
|
2959
|
+
"isprintable",
|
|
2960
|
+
"isspace",
|
|
2961
|
+
"istitle",
|
|
2962
|
+
"isupper",
|
|
2963
|
+
"join",
|
|
2964
|
+
"ljust",
|
|
2965
|
+
"lower",
|
|
2966
|
+
"lstrip",
|
|
2967
|
+
"maketrans",
|
|
2968
|
+
"partition",
|
|
2969
|
+
"removeprefix",
|
|
2970
|
+
"removesuffix",
|
|
2971
|
+
"replace",
|
|
2972
|
+
"rfind",
|
|
2973
|
+
"rindex",
|
|
2974
|
+
"rjust",
|
|
2975
|
+
"rpartition",
|
|
2976
|
+
"rsplit",
|
|
2977
|
+
"rstrip",
|
|
2978
|
+
"split",
|
|
2979
|
+
"splitlines",
|
|
2980
|
+
"startswith",
|
|
2981
|
+
"strip",
|
|
2982
|
+
"swapcase",
|
|
2983
|
+
"title",
|
|
2984
|
+
"translate",
|
|
2985
|
+
"upper",
|
|
2986
|
+
"zfill"
|
|
2987
|
+
]);
|
|
2724
2988
|
function enumMemberName(valueName) {
|
|
2725
|
-
return PYTHON_KEYWORDS.has(valueName) || CHOICES_RESERVED.has(valueName) ? `${valueName}_` : valueName;
|
|
2989
|
+
return PYTHON_KEYWORDS.has(valueName) || CHOICES_RESERVED.has(valueName) || STR_METHODS.has(valueName) ? `${valueName}_` : valueName;
|
|
2726
2990
|
}
|
|
2727
2991
|
function resolveDjangoField(field) {
|
|
2728
2992
|
const base = prismaTypeToDjangoField(field.type);
|
|
@@ -3125,9 +3389,9 @@ const ON_DELETE = {
|
|
|
3125
3389
|
NoAction: "models.DO_NOTHING",
|
|
3126
3390
|
SetDefault: "models.SET_DEFAULT"
|
|
3127
3391
|
};
|
|
3128
|
-
function onDeleteFor(
|
|
3129
|
-
if (
|
|
3130
|
-
return
|
|
3392
|
+
function onDeleteFor(relationField, scalarField) {
|
|
3393
|
+
if (relationField.relationOnDelete && ON_DELETE[relationField.relationOnDelete]) return ON_DELETE[relationField.relationOnDelete];
|
|
3394
|
+
return scalarField.isRequired ? "models.RESTRICT" : "models.SET_NULL";
|
|
3131
3395
|
}
|
|
3132
3396
|
function generateForeignKeyField(model, relationField, scalarField, allModels, names, isPk) {
|
|
3133
3397
|
const attrName = attrNameOf(names, model, relationField);
|
|
@@ -3143,12 +3407,12 @@ function generateForeignKeyField(model, relationField, scalarField, allModels, n
|
|
|
3143
3407
|
const toField = referencedField && targetModel && !(targetPk.length === 1 && targetPk[0] === referencedName) ? `to_field=${toPythonString(attrNameOf(names, targetModel, referencedField))}` : null;
|
|
3144
3408
|
return ` ${attrName} = models.${ctor}(${[
|
|
3145
3409
|
target,
|
|
3146
|
-
`on_delete=${onDeleteFor(relationField)}`,
|
|
3410
|
+
`on_delete=${onDeleteFor(relationField, scalarField)}`,
|
|
3147
3411
|
`related_name=${relatedName}`,
|
|
3148
3412
|
toField,
|
|
3149
3413
|
isPk ? "primary_key=True" : null,
|
|
3150
3414
|
columnName !== `${attrName}_id` ? `db_column=${toPythonString(columnName)}` : null,
|
|
3151
|
-
!
|
|
3415
|
+
!scalarField.isRequired ? "null=True" : null,
|
|
3152
3416
|
ctor === "ForeignKey" ? "db_index=False" : null,
|
|
3153
3417
|
...formatDefaultArgs(model, scalarField, isPk, names)
|
|
3154
3418
|
].filter((a) => a !== null).join(", ")})`;
|
|
@@ -3270,7 +3534,7 @@ function generateMetaLines(model, indexes, names) {
|
|
|
3270
3534
|
] : [],
|
|
3271
3535
|
...indexEntries.length > 0 ? [
|
|
3272
3536
|
" indexes = [",
|
|
3273
|
-
...indexEntries.map((i) => ` ${i},`),
|
|
3537
|
+
...[...new Set(indexEntries)].map((i) => ` ${i},`),
|
|
3274
3538
|
" ]"
|
|
3275
3539
|
] : []
|
|
3276
3540
|
];
|
|
@@ -4708,16 +4972,17 @@ function ectoSchemas(models, app, allModels, enums, options = {}) {
|
|
|
4708
4972
|
if (a.references !== "id") opts.push(`references: :${a.references}`);
|
|
4709
4973
|
return ` belongs_to(:${snakeAssocName}, ${appName}.${makePascalCase(a.targetModel)}, ${opts.join(", ")})`;
|
|
4710
4974
|
});
|
|
4975
|
+
const namesReferences = (references) => references !== "id" || pk.line === "@primary_key false";
|
|
4711
4976
|
const hasOneLines = associations.hasOne.map((a) => {
|
|
4712
4977
|
const snakeFk = makeSnakeCase(a.foreignKey);
|
|
4713
4978
|
const snakeAssocName = makeSnakeCase(a.name);
|
|
4714
|
-
const referencesOpt = a.references
|
|
4979
|
+
const referencesOpt = namesReferences(a.references) ? `, references: :${a.references}` : "";
|
|
4715
4980
|
return ` has_one(:${snakeAssocName}, ${appName}.${makePascalCase(a.targetModel)}, foreign_key: :${snakeFk}${referencesOpt})`;
|
|
4716
4981
|
});
|
|
4717
4982
|
const hasManyLines = associations.hasMany.map((a) => {
|
|
4718
4983
|
const snakeFk = makeSnakeCase(a.foreignKey);
|
|
4719
4984
|
const snakeAssocName = makeSnakeCase(a.name);
|
|
4720
|
-
const referencesOpt = a.references
|
|
4985
|
+
const referencesOpt = namesReferences(a.references) ? `, references: :${a.references}` : "";
|
|
4721
4986
|
return ` has_many(:${snakeAssocName}, ${appName}.${makePascalCase(a.targetModel)}, foreign_key: :${snakeFk}${referencesOpt})`;
|
|
4722
4987
|
});
|
|
4723
4988
|
const manyToManyLines = associations.manyToMany.map((a) => {
|
|
@@ -11611,7 +11876,7 @@ function dateTimeGoType(field) {
|
|
|
11611
11876
|
const element = nativeName === "Date" ? "Date" : nativeName === "Time" || nativeName === "Timetz" ? "TimeOfDay" : "DateTime";
|
|
11612
11877
|
return field.isList ? `${element}List` : element;
|
|
11613
11878
|
}
|
|
11614
|
-
function buildGormTags(field, isPk, isCompositePk, compositeIndexTags, enums, provider) {
|
|
11879
|
+
function buildGormTags(field, isPk, isCompositePk, compositeIndexTags, enums, provider, fieldName = goFieldName(field.name)) {
|
|
11615
11880
|
const columnName = field.dbName ?? field.name;
|
|
11616
11881
|
const isUuidDefault = isFunctionDefault(field.default) && field.default.name === "uuid";
|
|
11617
11882
|
const isUlidDefault = isFunctionDefault(field.default) && field.default.name === "ulid";
|
|
@@ -11633,8 +11898,7 @@ function buildGormTags(field, isPk, isCompositePk, compositeIndexTags, enums, pr
|
|
|
11633
11898
|
return provider === "sqlite" ? `'${iso.replace("Z", "+00:00")}'` : `'${iso.slice(0, 10)} ${iso.slice(11, 23)}'`;
|
|
11634
11899
|
})();
|
|
11635
11900
|
const defaultVal = dbGeneratedExpr ?? dateTimeDefault ?? ((!isPk || isCompositePk) && !isNowDefault && !field.isUpdatedAt ? enumMappedDefault ?? formatGoDefault(field.default, field.type, field.kind) : null);
|
|
11636
|
-
const
|
|
11637
|
-
const isDateTime = isDateTimeScalar(field);
|
|
11901
|
+
const isTracked = isDateTimeScalar(field) || ["Int", "BigInt"].includes(field.type);
|
|
11638
11902
|
return `\`gorm:"${[
|
|
11639
11903
|
`column:${columnName}`,
|
|
11640
11904
|
isPk ? "primaryKey" : null,
|
|
@@ -11646,8 +11910,8 @@ function buildGormTags(field, isPk, isCompositePk, compositeIndexTags, enums, pr
|
|
|
11646
11910
|
isDateTimeList(field) ? `type:${nativeType ?? "timestamp(3)"}[]` : includeNativeType ? `type:${nativeType}` : null,
|
|
11647
11911
|
field.isList && field.kind !== "object" && !isDateTimeList(field) ? "serializer:json" : null,
|
|
11648
11912
|
defaultVal !== null ? `default:${defaultVal}` : null,
|
|
11649
|
-
|
|
11650
|
-
|
|
11913
|
+
isTracked && fieldName === "CreatedAt" ? "autoCreateTime:false" : null,
|
|
11914
|
+
isTracked && fieldName === "UpdatedAt" ? "autoUpdateTime:false" : null,
|
|
11651
11915
|
field.isRequired && !isPk ? "not null" : null
|
|
11652
11916
|
].filter((p) => p !== null).join(";")}" json:"${columnName}"\``;
|
|
11653
11917
|
}
|
|
@@ -11725,6 +11989,22 @@ function goFieldName(name) {
|
|
|
11725
11989
|
const pascal = splitGoWords(name).join("");
|
|
11726
11990
|
return GENERATED_METHOD_NAMES.has(pascal) ? `${pascal}_` : pascal;
|
|
11727
11991
|
}
|
|
11992
|
+
/**
|
|
11993
|
+
* The Go name of each field of a model. Two fields can become one name (`createdAt` beside the
|
|
11994
|
+
* `created_at` an OAuth provider returns, both `CreatedAt`): the first declared keeps it and the
|
|
11995
|
+
* other is numbered (`CreatedAt1`), its `column:` tag still naming its own column. Scalars are
|
|
11996
|
+
* named before relations, so a relation never moves a column's field.
|
|
11997
|
+
*/
|
|
11998
|
+
function goFieldNames(model) {
|
|
11999
|
+
return allocate([...model.fields.filter((f) => f.kind !== "object"), ...model.fields.filter((f) => f.kind === "object")].map((f) => ({
|
|
12000
|
+
key: f.name,
|
|
12001
|
+
candidate: goFieldName(f.name)
|
|
12002
|
+
})), [], (name) => name);
|
|
12003
|
+
}
|
|
12004
|
+
function goFieldNameIn(models, modelName, fieldName) {
|
|
12005
|
+
const model = models.find((m) => m.name === modelName);
|
|
12006
|
+
return (model ? goFieldNames(model).get(fieldName) : void 0) ?? goFieldName(fieldName);
|
|
12007
|
+
}
|
|
11728
12008
|
function goModelName(name) {
|
|
11729
12009
|
return splitGoWords(name).join("");
|
|
11730
12010
|
}
|
|
@@ -11756,9 +12036,9 @@ function createdTimeExpr(field) {
|
|
|
11756
12036
|
const at = new Date(field.default);
|
|
11757
12037
|
return `time.Date(${at.getUTCFullYear()}, ${at.getUTCMonth() + 1}, ${at.getUTCDate()}, ${at.getUTCHours()}, ${at.getUTCMinutes()}, ${at.getUTCSeconds()}, ${at.getUTCMilliseconds() * 1e6}, time.UTC)`;
|
|
11758
12038
|
}
|
|
11759
|
-
function generateBeforeCreateHook(model) {
|
|
12039
|
+
function generateBeforeCreateHook(model, names) {
|
|
11760
12040
|
const assignments = model.fields.flatMap((field) => {
|
|
11761
|
-
const fieldName = goFieldName(field.name);
|
|
12041
|
+
const fieldName = names.get(field.name) ?? goFieldName(field.name);
|
|
11762
12042
|
const idExpr = field.kind === "scalar" && field.type === "String" && !field.isList ? generatedIdExpr$1(field) : null;
|
|
11763
12043
|
if (idExpr !== null) return field.isRequired ? [
|
|
11764
12044
|
`\tif m.${fieldName} == "" {`,
|
|
@@ -11794,7 +12074,7 @@ function generateBeforeCreateHook(model) {
|
|
|
11794
12074
|
"}"
|
|
11795
12075
|
];
|
|
11796
12076
|
}
|
|
11797
|
-
function generateBeforeUpdateHook(model) {
|
|
12077
|
+
function generateBeforeUpdateHook(model, names) {
|
|
11798
12078
|
const stamped = model.fields.filter((field) => isDateTimeScalar(field) && field.isUpdatedAt);
|
|
11799
12079
|
if (stamped.length === 0) return [];
|
|
11800
12080
|
return [
|
|
@@ -11802,7 +12082,7 @@ function generateBeforeUpdateHook(model) {
|
|
|
11802
12082
|
`func (*${goModelName(model.name)}) BeforeUpdate(tx *gorm.DB) error {`,
|
|
11803
12083
|
" now := tx.NowFunc().UTC().Truncate(time.Millisecond)",
|
|
11804
12084
|
...stamped.flatMap((field) => {
|
|
11805
|
-
const fieldName = goFieldName(field.name);
|
|
12085
|
+
const fieldName = names.get(field.name) ?? goFieldName(field.name);
|
|
11806
12086
|
return [
|
|
11807
12087
|
`\tif !tx.Statement.Changed("${fieldName}") {`,
|
|
11808
12088
|
`\t\ttx.Statement.SetColumn("${fieldName}", ${field.isRequired ? "" : "&"}${dateTimeGoType(field)}{Time: now})`,
|
|
@@ -11813,8 +12093,7 @@ function generateBeforeUpdateHook(model) {
|
|
|
11813
12093
|
"}"
|
|
11814
12094
|
];
|
|
11815
12095
|
}
|
|
11816
|
-
function generateStructField(field, isPk, isCompositePk, compositeIndexTags, enums, provider) {
|
|
11817
|
-
const fieldName = goFieldName(field.name);
|
|
12096
|
+
function generateStructField(field, fieldName, isPk, isCompositePk, compositeIndexTags, enums, provider) {
|
|
11818
12097
|
const def = field.default;
|
|
11819
12098
|
const hasNonZeroDefault = field.kind === "scalar" && !isPk && [
|
|
11820
12099
|
"Int",
|
|
@@ -11828,7 +12107,7 @@ function generateStructField(field, isPk, isCompositePk, compositeIndexTags, enu
|
|
|
11828
12107
|
return [
|
|
11829
12108
|
fieldName,
|
|
11830
12109
|
isDateTimeList(field) ? dateTimeGoType(field) : field.isList ? `[]${field.kind === "enum" ? "string" : prismaTypeToGoType(field.type, true)}` : isDateTimeScalar(field) ? `${field.isRequired ? "" : "*"}${dateTimeGoType(field)}` : scalarType,
|
|
11831
|
-
buildGormTags(field, isPk, isCompositePk, compositeIndexTags, enums, provider)
|
|
12110
|
+
buildGormTags(field, isPk, isCompositePk, compositeIndexTags, enums, provider, fieldName)
|
|
11832
12111
|
];
|
|
11833
12112
|
}
|
|
11834
12113
|
function needsReferencesTag(references) {
|
|
@@ -11848,11 +12127,13 @@ function constraintTag(onDelete, onUpdate) {
|
|
|
11848
12127
|
function buildRelationTag(parts) {
|
|
11849
12128
|
return `\`gorm:"${parts.join(";")}"\``;
|
|
11850
12129
|
}
|
|
11851
|
-
function generateRelationFields(associations) {
|
|
12130
|
+
function generateRelationFields(model, allModels, associations) {
|
|
12131
|
+
const of = (modelName) => (name) => goFieldNameIn(allModels, modelName, name);
|
|
12132
|
+
const own = of(model.name);
|
|
11852
12133
|
const belongsToLines = associations.belongsTo.map((assoc) => {
|
|
11853
|
-
const fieldName =
|
|
11854
|
-
const fkFieldName = assoc.foreignKeys.map(
|
|
11855
|
-
const refsFieldName = assoc.referencesList.map(
|
|
12134
|
+
const fieldName = own(assoc.name);
|
|
12135
|
+
const fkFieldName = assoc.foreignKeys.map(own).join(",");
|
|
12136
|
+
const refsFieldName = assoc.referencesList.map(of(assoc.targetModel)).join(",");
|
|
11856
12137
|
const isComposite = assoc.foreignKeys.length > 1;
|
|
11857
12138
|
const isAmbiguous = fieldName !== goModelName(assoc.targetModel) || associations.belongsTo.filter((a) => a.targetModel === assoc.targetModel).length > 1;
|
|
11858
12139
|
const isGuessed = fkFieldName === `${fieldName}${refsFieldName}`;
|
|
@@ -11866,35 +12147,35 @@ function generateRelationFields(associations) {
|
|
|
11866
12147
|
});
|
|
11867
12148
|
const hasManyLines = associations.hasMany.map((assoc) => {
|
|
11868
12149
|
const tagParts = [
|
|
11869
|
-
`foreignKey:${assoc.foreignKeys.map(
|
|
11870
|
-
...assoc.foreignKeys.length > 1 || needsReferencesTag(assoc.references) ? [`references:${assoc.referencesList.map(
|
|
12150
|
+
`foreignKey:${assoc.foreignKeys.map(of(assoc.targetModel)).join(",")}`,
|
|
12151
|
+
...assoc.foreignKeys.length > 1 || needsReferencesTag(assoc.references) ? [`references:${assoc.referencesList.map(own).join(",")}`] : [],
|
|
11871
12152
|
...[constraintTag(assoc.onDelete, assoc.onUpdate)].filter((c) => c !== null)
|
|
11872
12153
|
];
|
|
11873
12154
|
return [
|
|
11874
|
-
|
|
12155
|
+
own(assoc.name),
|
|
11875
12156
|
`[]${goModelName(assoc.targetModel)}`,
|
|
11876
12157
|
buildRelationTag(tagParts)
|
|
11877
12158
|
];
|
|
11878
12159
|
});
|
|
11879
12160
|
const hasOneLines = associations.hasOne.map((assoc) => {
|
|
11880
12161
|
const tagParts = [
|
|
11881
|
-
`foreignKey:${assoc.foreignKeys.map(
|
|
11882
|
-
...assoc.foreignKeys.length > 1 || needsReferencesTag(assoc.references) ? [`references:${assoc.referencesList.map(
|
|
12162
|
+
`foreignKey:${assoc.foreignKeys.map(of(assoc.targetModel)).join(",")}`,
|
|
12163
|
+
...assoc.foreignKeys.length > 1 || needsReferencesTag(assoc.references) ? [`references:${assoc.referencesList.map(own).join(",")}`] : [],
|
|
11883
12164
|
...[constraintTag(assoc.onDelete, assoc.onUpdate)].filter((c) => c !== null)
|
|
11884
12165
|
];
|
|
11885
12166
|
return [
|
|
11886
|
-
|
|
12167
|
+
own(assoc.name),
|
|
11887
12168
|
`*${goModelName(assoc.targetModel)}`,
|
|
11888
12169
|
buildRelationTag(tagParts)
|
|
11889
12170
|
];
|
|
11890
12171
|
});
|
|
11891
12172
|
const manyToManyLines = associations.manyToMany.map((assoc) => {
|
|
11892
12173
|
const joinTable = `_${assoc.relationName}`;
|
|
11893
|
-
const [
|
|
12174
|
+
const [ownColumn, related] = assoc.isSideA ? ["A", "B"] : ["B", "A"];
|
|
11894
12175
|
return [
|
|
11895
|
-
|
|
12176
|
+
own(assoc.name),
|
|
11896
12177
|
`[]${goModelName(assoc.targetModel)}`,
|
|
11897
|
-
`\`gorm:"many2many:${joinTable};joinForeignKey:${
|
|
12178
|
+
`\`gorm:"many2many:${joinTable};joinForeignKey:${ownColumn};joinReferences:${related}"\``
|
|
11898
12179
|
];
|
|
11899
12180
|
});
|
|
11900
12181
|
return [
|
|
@@ -11942,12 +12223,14 @@ function generateModelStruct(model, allModels, enums, indexes, provider) {
|
|
|
11942
12223
|
const associations = getAssociations$2(model, allModels);
|
|
11943
12224
|
const compositeTagMap = collectCompositeIndexTags(model, indexes);
|
|
11944
12225
|
const tableName = model.dbName ?? model.name;
|
|
11945
|
-
const
|
|
12226
|
+
const scalarFields = model.fields.filter((f) => f.kind !== "object");
|
|
12227
|
+
const names = goFieldNames(model);
|
|
12228
|
+
const fieldLines = scalarFields.map((field) => {
|
|
11946
12229
|
const isPk = field.isId || compositePkFieldNames.has(field.name);
|
|
11947
12230
|
const fieldIndexTags = compositeTagMap.get(field.name) ?? [];
|
|
11948
|
-
return generateStructField(field, isPk, isCompositePk, fieldIndexTags, enums, provider);
|
|
12231
|
+
return generateStructField(field, names.get(field.name) ?? goFieldName(field.name), isPk, isCompositePk, fieldIndexTags, enums, provider);
|
|
11949
12232
|
});
|
|
11950
|
-
const relationLines = generateRelationFields(associations);
|
|
12233
|
+
const relationLines = generateRelationFields(model, allModels, associations);
|
|
11951
12234
|
const tableNameMethod = [
|
|
11952
12235
|
"",
|
|
11953
12236
|
`func (${goModelName(model.name)}) TableName() string {`,
|
|
@@ -11959,8 +12242,8 @@ function generateModelStruct(model, allModels, enums, indexes, provider) {
|
|
|
11959
12242
|
...alignFields([...fieldLines, ...relationLines]),
|
|
11960
12243
|
"}",
|
|
11961
12244
|
...tableNameMethod,
|
|
11962
|
-
...generateBeforeCreateHook(model),
|
|
11963
|
-
...generateBeforeUpdateHook(model)
|
|
12245
|
+
...generateBeforeCreateHook(model, names),
|
|
12246
|
+
...generateBeforeUpdateHook(model, names)
|
|
11964
12247
|
].join("\n");
|
|
11965
12248
|
}
|
|
11966
12249
|
function hasImplicitManyToMany(models) {
|
|
@@ -13687,8 +13970,8 @@ function generateM2MEntity(leftModel, rightModel, relationName, allModels, serde
|
|
|
13687
13970
|
const rightFk = isSelf ? "b" : `${makeSnakeCase(sortedRight)}_id`;
|
|
13688
13971
|
const leftCol = isSelf ? "A" : makePascalCase(`${makeSnakeCase(sortedLeft)}Id`);
|
|
13689
13972
|
const rightCol = isSelf ? "B" : makePascalCase(`${makeSnakeCase(sortedRight)}Id`);
|
|
13690
|
-
const leftVariant = isSelf ? "A" : sortedLeft;
|
|
13691
|
-
const rightVariant = isSelf ? "B" : sortedRight;
|
|
13973
|
+
const leftVariant = isSelf ? "A" : makePascalCase(sortedLeft);
|
|
13974
|
+
const rightVariant = isSelf ? "B" : makePascalCase(sortedRight);
|
|
13692
13975
|
const leftType = pkRustType(sortedLeft, allModels);
|
|
13693
13976
|
const rightType = pkRustType(sortedRight, allModels);
|
|
13694
13977
|
const leftKey = makePascalCase(allModels.find((m) => m.name === sortedLeft)?.fields.find((f) => f.isId)?.name ?? "id");
|
|
@@ -13817,7 +14100,7 @@ function generatePreludeRs(models) {
|
|
|
13817
14100
|
return `${models.map((m) => ({
|
|
13818
14101
|
module: rustModule(m.name).ident,
|
|
13819
14102
|
name: m.name
|
|
13820
|
-
})).toSorted((a, b) => a.module < b.module ? -1 : a.module > b.module ? 1 : 0).map(({ module, name }) => `pub use super::${module}::Entity as ${name};`).join("\n")}\n`;
|
|
14103
|
+
})).toSorted((a, b) => a.module < b.module ? -1 : a.module > b.module ? 1 : 0).map(({ module, name }) => name === "Entity" ? `pub use super::${module}::Entity;` : `pub use super::${module}::Entity as ${name};`).join("\n")}\n`;
|
|
13821
14104
|
}
|
|
13822
14105
|
function collectM2MPairs(models) {
|
|
13823
14106
|
const pairs = models.flatMap((model) => getAssociations$1(model, models).manyToMany.map((assoc) => {
|
|
@@ -14258,6 +14541,7 @@ function getAssociations(model, allModels) {
|
|
|
14258
14541
|
if (end.kind === "hasMany") hasMany.push({
|
|
14259
14542
|
name: field.name,
|
|
14260
14543
|
targetModel: field.type,
|
|
14544
|
+
inverse: fkField,
|
|
14261
14545
|
foreignKey,
|
|
14262
14546
|
foreignKeys,
|
|
14263
14547
|
isList: true,
|
|
@@ -14266,6 +14550,7 @@ function getAssociations(model, allModels) {
|
|
|
14266
14550
|
else hasOne.push({
|
|
14267
14551
|
name: field.name,
|
|
14268
14552
|
targetModel: field.type,
|
|
14553
|
+
inverse: fkField,
|
|
14269
14554
|
foreignKey,
|
|
14270
14555
|
foreignKeys,
|
|
14271
14556
|
isList: false,
|
|
@@ -14456,6 +14741,26 @@ function findM2MBackPopulates(targetModelName, sourceModelName, sourceFieldName,
|
|
|
14456
14741
|
const backField = targetModel?.fields.find((f) => f.kind === "object" && f.type === sourceModelName && f.relationName === relationName && !(targetModelName === sourceModelName && f.name === sourceFieldName));
|
|
14457
14742
|
return backField ? attributeName(targetModel, backField.name) : pythonAttrName(makeSnakeCase(sourceModelName));
|
|
14458
14743
|
}
|
|
14744
|
+
/**
|
|
14745
|
+
* The `overlaps=` of a relationship that writes the foreign key `relation` holds (the many-to-one
|
|
14746
|
+
* itself or the collection on the other side): every other relationship that writes one of the
|
|
14747
|
+
* same columns. A composite key that shares a column with another relation
|
|
14748
|
+
* (`[projectId, environment]` beside `projectId`) has two relationships copying the column, which
|
|
14749
|
+
* SQLAlchemy warns of unless each names the others. The pair of a back_populates is left out, as
|
|
14750
|
+
* SQLAlchemy leaves it.
|
|
14751
|
+
*
|
|
14752
|
+
* @example
|
|
14753
|
+
* ```python
|
|
14754
|
+
* environment_ref: Mapped[Optional["ProjectEnvironment"]] = relationship(overlaps="database_configs,project", back_populates="database_configs")
|
|
14755
|
+
* ```
|
|
14756
|
+
*/
|
|
14757
|
+
function overlapsClause(holdingModelName, relation, allModels) {
|
|
14758
|
+
const holding = allModels.find((m) => m.name === holdingModelName);
|
|
14759
|
+
const keys = relation.relationFromFields ?? [];
|
|
14760
|
+
const names = (holding?.fields ?? []).flatMap((f) => f.kind === "object" && f.name !== relation.name && (f.relationFromFields ?? []).some((key) => keys.includes(key)) ? [attributeName(holding, f.name), findBackPopulates(f.type, holdingModelName, f.relationFromFields?.[0] ?? "", allModels, f.name)] : []);
|
|
14761
|
+
const sorted = [...new Set(names)].toSorted();
|
|
14762
|
+
return sorted.length > 0 ? `overlaps="${sorted.join(",")}", ` : "";
|
|
14763
|
+
}
|
|
14459
14764
|
function generateColumn(field, isPk, isFk, associations, allModels, enumMap, provider, model, isMapperKey) {
|
|
14460
14765
|
const tableName = model.dbName ?? model.name;
|
|
14461
14766
|
const columnName = field.dbName ?? field.name;
|
|
@@ -14566,7 +14871,9 @@ function generateBelongsToRelationships(associations, model, allModels) {
|
|
|
14566
14871
|
const identity = primaryKeyFields$1(model);
|
|
14567
14872
|
const remoteClause = assoc.targetModel === model.name && identity.length > 0 ? `remote_side=[${identity.map((name) => attributeName(model, name)).join(", ")}], ` : "";
|
|
14568
14873
|
const target = className(assoc.targetModel);
|
|
14569
|
-
|
|
14874
|
+
const mappedType = assoc.optional ? `Optional["${target}"]` : `"${target}"`;
|
|
14875
|
+
const relation = model.fields.find((f) => f.name === assoc.name);
|
|
14876
|
+
return ` ${snakeName}: Mapped[${mappedType}] = relationship(${remoteClause}${fkClause}${relation ? overlapsClause(model.name, relation, allModels) : ""}back_populates="${backPop}")`;
|
|
14570
14877
|
});
|
|
14571
14878
|
}
|
|
14572
14879
|
function inverseForeignKeys(targetModelName, foreignKeys, allModels) {
|
|
@@ -14579,7 +14886,8 @@ function generateHasManyRelationships(associations, model, allModels) {
|
|
|
14579
14886
|
const snakeName = attributeName(model, assoc.name);
|
|
14580
14887
|
const backPop = findBackPopulates(assoc.targetModel, model.name, assoc.foreignKey, allModels, assoc.name);
|
|
14581
14888
|
const fkClause = needsForeignKeysParam(model.name, assoc.targetModel, allModels) ? `foreign_keys=${inverseForeignKeys(assoc.targetModel, assoc.foreignKeys, allModels)}, ` : "";
|
|
14582
|
-
|
|
14889
|
+
const overlaps = overlapsClause(assoc.targetModel, assoc.inverse, allModels);
|
|
14890
|
+
return ` ${snakeName}: Mapped[list["${className(assoc.targetModel)}"]] = relationship(${fkClause}${deleteClause(assoc.onDelete)}${overlaps}back_populates="${backPop}")`;
|
|
14583
14891
|
});
|
|
14584
14892
|
}
|
|
14585
14893
|
function generateHasOneRelationships(associations, model, allModels) {
|
|
@@ -14588,7 +14896,9 @@ function generateHasOneRelationships(associations, model, allModels) {
|
|
|
14588
14896
|
const backPop = findBackPopulates(assoc.targetModel, model.name, assoc.foreignKey, allModels, assoc.name);
|
|
14589
14897
|
const fkClause = needsForeignKeysParam(model.name, assoc.targetModel, allModels) ? `foreign_keys=${inverseForeignKeys(assoc.targetModel, assoc.foreignKeys, allModels)}, ` : "";
|
|
14590
14898
|
const target = className(assoc.targetModel);
|
|
14591
|
-
|
|
14899
|
+
const mappedType = assoc.optional ? `Optional["${target}"]` : `"${target}"`;
|
|
14900
|
+
const overlaps = overlapsClause(assoc.targetModel, assoc.inverse, allModels);
|
|
14901
|
+
return ` ${snakeName}: Mapped[${mappedType}] = relationship(${fkClause}${deleteClause(assoc.onDelete)}${overlaps}back_populates="${backPop}")`;
|
|
14592
14902
|
});
|
|
14593
14903
|
}
|
|
14594
14904
|
function generateManyToManyRelationships(associations, model, allModels, m2mTables) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hekireki",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"description": "Hekireki is a code generator from Prisma schema to validation schemas, ORM models, OpenAPI and ER diagrams, with a Studio for your schema and its data",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"activerecord",
|