1
0

codegen.proto 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. syntax = "proto3";
  2. package plugin;
  3. option go_package = "github.com/kyleconroy/sqlc/internal/plugin";
  4. message File
  5. {
  6. string name = 1 [json_name="name"];
  7. bytes contents = 2 [json_name="contents"];
  8. }
  9. message Override {
  10. // name of the type to use, e.g. `github.com/segmentio/ksuid.KSUID` or `mymodule.Type`
  11. string code_type = 1 [json_name="code_type"];
  12. // name of the type to use, e.g. `text`
  13. string db_type = 3 [json_name="db_type"];
  14. // True if the override should apply to a nullable database type
  15. bool nullable = 5 [json_name="nullable"];
  16. // fully qualified name of the column, e.g. `accounts.id`
  17. string column = 6 [json_name="column"];
  18. Identifier table = 7 [json_name="table"];
  19. string column_name = 8 [json_name="column_name"];
  20. PythonType python_type = 9;
  21. }
  22. message PythonType
  23. {
  24. string module = 1;
  25. string name = 2;
  26. }
  27. message Settings
  28. {
  29. string version = 1 [json_name="version"];
  30. string engine = 2 [json_name="engine"];
  31. repeated string schema = 3 [json_name="schema"];
  32. repeated string queries = 4 [json_name="queries"];
  33. map<string, string> rename = 5 [json_name="rename"];
  34. repeated Override overrides = 6 [json_name="overrides"];
  35. // TODO: Refactor codegen settings
  36. PythonCode python = 8;
  37. KotlinCode kotlin = 9;
  38. }
  39. message PythonCode
  40. {
  41. bool emit_exact_table_names = 1;
  42. bool emit_sync_querier = 2;
  43. bool emit_async_querier = 3;
  44. string package = 4;
  45. string out = 5;
  46. }
  47. message KotlinCode
  48. {
  49. bool emit_exact_table_names = 1;
  50. string package = 2;
  51. string out = 3;
  52. }
  53. message Catalog
  54. {
  55. string comment = 1;
  56. string default_schema = 2;
  57. string name = 3;
  58. repeated Schema schemas = 4;
  59. }
  60. message Schema
  61. {
  62. string comment = 1;
  63. string name = 2;
  64. repeated Table tables = 3;
  65. repeated Enum enums = 4;
  66. }
  67. message Enum
  68. {
  69. string name = 1;
  70. repeated string vals = 2;
  71. string comment = 3;
  72. }
  73. message Table
  74. {
  75. Identifier rel = 1;
  76. repeated Column columns = 2;
  77. string comment = 3;
  78. }
  79. message Identifier
  80. {
  81. string catalog = 1;
  82. string schema = 2;
  83. string name = 3;
  84. }
  85. message Column
  86. {
  87. string name = 1;
  88. bool not_null = 3;
  89. bool is_array = 4;
  90. string comment = 5;
  91. int32 length = 6;
  92. bool is_named_param = 7;
  93. bool is_func_call = 8;
  94. // XXX: Figure out what PostgreSQL calls `foo.id`
  95. string scope = 9;
  96. Identifier table = 10;
  97. string table_alias = 11;
  98. Identifier type = 12;
  99. string data_type = 13;
  100. }
  101. message Query
  102. {
  103. string text = 1 [json_name="text"];
  104. string name = 2 [json_name="name"];
  105. string cmd = 3 [json_name="cmd"];
  106. repeated Column columns = 4 [json_name="columns"];
  107. repeated Parameter params = 5 [json_name="parameters"];
  108. repeated string comments = 6 [json_name="comments"];
  109. string filename = 7 [json_name="filename"];
  110. }
  111. message Parameter
  112. {
  113. int32 number = 1 [json_name="number"];
  114. Column column = 2 [json_name="column"];
  115. }
  116. message CodeGenRequest
  117. {
  118. Settings settings = 1 [json_name="settings"];
  119. Catalog catalog = 2 [json_name="catalog"];
  120. repeated Query queries = 3 [json_name="queries"];
  121. }
  122. message CodeGenResponse
  123. {
  124. repeated File files = 1 [json_name="files"];
  125. }