Repository: candlecorp/wick (language: rust)

Issue:
Breaking due to name change
**Describe the bug**
The SQL component breaks when I set the component name to any name. 

**To Reproduce**
Steps to reproduce the behavior

**Expected behavior**
A clear and short description of what you expected to happen.

**Actual behavior**
A clear and short description of what actually happens.

**Environment:**
 - OS
 - Architecture
 - Build Version

**Additional context**
Add any other context about the problem here.

Breaking due to name change
**Describe the bug**
The SQL component breaks when I set the component name to any name. 

**To Reproduce**
Steps to reproduce the behavior

**Expected behavior**
A clear and short description of what you expected to happen.

**Actual behavior**
A clear and short description of what actually happens.

**Environment:**
 - OS
 - Architecture
 - Build Version

**Additional context**
Add any other context about the problem here.



Discussion / hints:

Fix patch:
diff --git a/crates/bins/wick/src/commands/invoke.rs b/crates/bins/wick/src/commands/invoke.rs
index abb03fa3b..4e6afbdb0 100644
--- a/crates/bins/wick/src/commands/invoke.rs
+++ b/crates/bins/wick/src/commands/invoke.rs
@@ -9,7 +9,7 @@ use wick_component_cli::options::DefaultCliOptions;
 use wick_component_cli::parse_args;
 use wick_config::WickConfiguration;
 use wick_host::ComponentHostBuilder;
-use wick_packet::{InherentData, Observer, Packet, PacketStream};
+use wick_packet::{InherentData, Packet, PacketStream};
 
 use crate::utils::{self, merge_config};
 
@@ -144,19 +144,21 @@ pub(crate) async fn handle_command(mut opts: InvokeCommand) -> Result<()> {
 
     let args = parse_args(&opts.args)?;
     trace!(args= ?args, "parsed CLI arguments");
-    let (tx, stream) = PacketStream::new_channels();
+    let mut packets = Vec::new();
     let mut seen_ports = HashSet::new();
     for packet in args {
       seen_ports.insert(packet.port().to_owned());
-      tx.send(packet)?;
+      packets.push(Ok(packet));
     }
     for packet in data {
       seen_ports.insert(packet.port().to_owned());
-      tx.send(packet)?;
+      packets.push(Ok(packet));
     }
     for port in seen_ports {
-      tx.send(Packet::done(port))?;
+      packets.push(Ok(Packet::done(port)));
     }
+    debug!(args= ?packets, "wick:invoke");
+    let stream = PacketStream::new(futures::stream::iter(packets));
 
     let stream = host.request(&component, stream, inherent_data).await?;
     utils::print_stream_json(stream, &opts.filter, opts.short, opts.raw).await?;
diff --git a/crates/components/wick-sqlx/src/component.rs b/crates/components/wick-sqlx/src/component.rs
index 2f1bb2b80..05257e39e 100644
--- a/crates/components/wick-sqlx/src/component.rs
+++ b/crates/components/wick-sqlx/src/component.rs
@@ -141,12 +141,12 @@ impl Component for SqlXComponent {
       };
 
       let input_list: Vec<_> = opdef.inputs.iter().map(|i| i.name.clone()).collect();
-      let mut inputs = wick_packet::split_stream(stream, input_list);
+      let mut input_streams = wick_packet::split_stream(stream, input_list);
       let (tx, rx) = PacketStream::new_channels();
       tokio::spawn(async move {
         'outer: loop {
-          for input in &mut inputs {
-            let mut inputs = Vec::new();
+          let mut inputs = Vec::new();
+          for input in &mut input_streams {
             inputs.push(input.next().await);
             let num_done = inputs.iter().filter(|r| r.is_none()).count();
             if num_done > 0 {
@@ -155,23 +155,23 @@ impl Component for SqlXComponent {
               }
               break 'outer;
             }
-            let results = inputs.into_iter().map(|r| r.unwrap()).collect::<Vec<_>>();
-            if let Some(Err(e)) = results.iter().find(|r| r.is_err()) {
-              let _ = tx.error(wick_packet::Error::component_error(e.to_string()));
-              break 'outer;
-            }
-            let results = results
-              .into_iter()
-              .enumerate()
-              .map(|(i, r)| (opdef.inputs[i].ty.clone(), r.unwrap()))
-              .collect::<Vec<_>>();
-            if results.iter().any(|(_, r)| r.is_done()) {
-              break 'outer;
-            }
+          }
+          let results = inputs.into_iter().map(|r| r.unwrap()).collect::<Vec<_>>();
+          if let Some(Err(e)) = results.iter().find(|r| r.is_err()) {
+            let _ = tx.error(wick_packet::Error::component_error(e.to_string()));
+            break 'outer;
+          }
+          let results = results
+            .into_iter()
+            .enumerate()
+            .map(|(i, r)| (opdef.inputs[i].ty.clone(), r.unwrap()))
+            .collect::<Vec<_>>();
+          if results.iter().any(|(_, r)| r.is_done()) {
+            break 'outer;
+          }
 
-            if let Err(e) = exec(client.clone(), tx.clone(), opdef.clone(), results, stmt.clone()).await {
-              error!(error = %e, "error executing query");
-            }
+          if let Err(e) = exec(client.clone(), tx.clone(), opdef.clone(), results, stmt.clone()).await {
+            error!(error = %e, "error executing query");
           }
         }
       });
diff --git a/crates/wick/wick-interface-types/src/signatures.rs b/crates/wick/wick-interface-types/src/signatures.rs
index 48ef1d691..4ecbcbde7 100644
--- a/crates/wick/wick-interface-types/src/signatures.rs
+++ b/crates/wick/wick-interface-types/src/signatures.rs
@@ -39,7 +39,7 @@ impl Field {
       name: name.as_ref().to_owned(),
       description: None,
       default: None,
-      required: false,
+      required: true,
       ty,
     }
   }
@@ -210,8 +210,7 @@ impl PartialEq for ComponentSignature {
     let config_equal = contents_equal(&self.config, &other.config);
     let wellknown_equal = contents_equal(&self.wellknown, &other.wellknown);
 
-    self.name == other.name
-      && self.format == other.format
+    self.format == other.format
       && self.metadata == other.metadata
       && types_equal
       && operations_equal
diff --git a/examples/postgres-component.yaml b/examples/postgres-component.yaml
new file mode 100644
index 000000000..1ea201e7f
--- /dev/null
+++ b/examples/postgres-component.yaml
@@ -0,0 +1,35 @@
+name: my_component
+kind: wick/component@v1
+resources:
+  - name: DBADDR
+    resource:
+      kind: wick/resource/url@v1
+      url: postgres://postgres:$TEST_PASSWORD@$TEST_HOST:$POSTGRES_PORT/wick_test
+component:
+  kind: wick/component/sql@v1
+  resource: DBADDR
+  tls: false
+  operations:
+    - name: get_user
+      inputs:
+        - name: id
+          type: u32
+      outputs:
+        - name: output
+          type: object
+      query: SELECT * FROM users WHERE id = $1
+      arguments:
+        - id
+    - name: set_user
+      inputs:
+        - name: name
+          type: string
+        - name: email
+          type: string
+      outputs:
+        - name: output
+          type: object
+      query: INSERT INTO users(name, email) VALUES ($1, $2)
+      arguments:
+        - name
+        - email


Test patch: