611 questions
1
vote
0
answers
89
views
Django ManyToMany self relationship with through model — user_from and user_to reversed behavior
I added following and followers by using intermediate model, it's ok but does not correctly specify objects in the intermediate model. I expect the user who follows must to be in the user_from field ...
3
votes
1
answer
58
views
Storing Future next to source of said Future
I have a type which semantically behaves like a stream but doesn't actually implement the futures_util::Stream trait. Instead, it has a method get_next which repeatedly returns a Future yielding the ...
0
votes
1
answer
110
views
Avoiding Self Referential Structs
I'm writing a program that operates on a Vault object. This Vault object contains a directories field which is a vec of Directory objects. So something like this
struct Vault{
directories: Vec<...
0
votes
1
answer
55
views
Self-reference entities SaveChanges failure!! Am I missing something?
I have an entity
public class ExpenseCategory
{
public int Id { get; set; }
public string Label { get; set; } = string.Empty;
public int? ParentId { get; set; }
public ExpenseCategory?...
1
vote
1
answer
116
views
Create 'static Stream from a Stream which is lifetime-coupled to its source
I have a certain API I have to use:
struct API;
struct Ctrl;
impl API{
fn get_stream(&self) -> (impl Stream<Item = i32> + '_, Ctrl) {
(futures::stream::iter(1..=5), Ctrl{}) // ...
0
votes
2
answers
108
views
self-reference mutate in R
Hellow, I'm trying to build a tibble by a mutate operation that needs a self reference filter.
My objectie is to get the maximum value of a variable for all the available values of that variable that ...
1
vote
1
answer
74
views
Prevent self-referencing relation in SurrealDB
I am trying to apply the table permissions system SurrealDB offers to enable row-level security in its tables, but am seeming to fail with a simple example:
DEFINE TABLE node SCHEMAFULL TYPE NORMAL;
...
0
votes
1
answer
44
views
How to override only method signature in typescript?
A have an external array-like interface I want to implement
interface ListOf<T> {
readonly length: number;
readonly [index: number]: T;
item(index: number): T | null;
// note the parent ...
0
votes
1
answer
154
views
Self relation in C# [duplicate]
I have a class called Person that has an attribute called friends from which is a list of type Person. Actually, I am going to create a many-to-many relationship between the Person class and itself.
...
0
votes
0
answers
92
views
Self-referential pointer to field inside of same ctypes structure doesn't output usable type
I'm trying to recreate this structure (from https://github.com/ac-custom-shaders-patch/acc-extension-config/wiki/Other-Things-%E2%80%93-Custom-AI#drawing-debug-lines)...
struct cai_debug_lines {
int ...
0
votes
1
answer
72
views
How can an `extension` reference the type of `this` in dart?
Let's say I have some datatypes, and I want a function gimmeThis() that simply returns this. Currently, the code in main() does not compile, because the result of gimmeThis() is MyClass. How can I ...
0
votes
1
answer
235
views
How can I create a tail recursive merge method in Scala on a self-referential tree structure (or is it even possible)?
UPDATE 2024.03.16: Provided code that produces the correct output, but is still not tail-recursive.
How can I create a tail recursive merge method in Scala on a self-referential tree structure (or is ...
1
vote
1
answer
287
views
Why self-reference a column from the same table in a SQL subquery?
I'm working on subqueries in the Google Data Analytics Course. There are many places you can rent bikes from. These places are bike stations. The query is to calculate the difference between average ...
1
vote
0
answers
214
views
How to nicely solve self-referencing object update error?
In my project I have a bunch of models, that are all derived from the class 'Entity'. Simplified, this means they all have the following properties:
public Guid Id { get; set; }
public DateTime ...
1
vote
0
answers
86
views
C convert array to a arguments for a function [duplicate]
I have a list of arguments of different types:
value_info args_array[10];
value_info is defined as follows:
typedef int int_type;
typedef float float_type;
typedef double double_type;
typedef bool ...
1
vote
0
answers
63
views
Declaring a variable of self-referencing generic type in C# 10.0
Good time of the day!
I have a generic interface which has a self-reference:
public interface IBuilder<TObject, TBuilder>
where TBuilder : IBuilder<TObject, TBuilder>
{
public ...
1
vote
1
answer
73
views
Raspberry Pi; use geany(.py) to create a new folder and address code to it?
Sorry if this is obvious; I'm new to Rpi and Linux in general.
Im trying to create code for a timelapse camera such that when it turns on, it starts taking images and saves them to a folder.
The part ...
0
votes
1
answer
89
views
Why can I not put statements into class scope? [closed]
#include<stdio.h>
#include<stdlib.h>
struct Node
{
int val;
struct Node *link;
(*link).val = 12; // error
};
int main()
{
struct Node *link=(struct Node*)malloc(sizeof(...
0
votes
1
answer
138
views
Actually pinning to the heap using alloc/dealloc in Rust?
This is something of a follow-up to a previous question of mine. TL;DR: I tried to create a self-referencing struct by heap allocating the self-referencee using a Box. It was pointed out that I can't ...
0
votes
1
answer
453
views
How to force @JoinColumn columnDefinition to ignore referenced columnDefinition
I have following code for self-referencing entity
@Data
@Builder
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table
public class Dictionary implements ...
0
votes
1
answer
224
views
Why doesn't my self-referential struct work (invalid memory reference)?
I am trying to implement a self-referential struct in rust.
Background
I am writing a crate which is based on another crate. The underlying crate exposes a type Transaction<'a> which requires a ...
0
votes
1
answer
349
views
API Platform 2: many-to-many relation does not persists
I have this situation on a project Im working on, made in Symfony 5 and API Framework 2 (latest 2 version):
we have a User entity App\Entity\User
now users can be Reps or PAs for other users. Any ...
1
vote
2
answers
31
views
T-SQL Sum Since Condition Last Met
I'm trying to do a sort of running total with a variable window size. I want to sum a value from the current row to the last time another row met a condition.
Mock Data: I want a formula for the last ...
2
votes
1
answer
130
views
SQL Server - Checking for integer (id) within hierarchy of ids
How would one go about checking whether a given ID is within a hierarchy of IDs? For example, let's say I have the following hierarchies in a self-referencing table called locations (e.g. these are ...
0
votes
1
answer
81
views
Efficient self-referencing 0..1 to 0..1 relationship
What is the best practice for such a relationship in regards to data consistency and performance?
My first instinct was to add a new self-referencing column:
ALTER TABLE Edata_auction
ADD COLUMN ...
-1
votes
1
answer
709
views
How do I add values to the same cell with its current value?
I am trying to add value of cell A1 to cell A2. However, I want to keep adding A1's value to A2's current value because I want to keep some monthly record and that is represented by A2. I will keep ...
0
votes
1
answer
210
views
Why is 'std::priority_queue.top()' changing returned object member values?
I'm writing an A* algorithm for Rush Hour (game) in order to learn the basics. For that I wrote a class named Board, which instances also act as the 'nodes' for the A* search.
For the algorithm to ...
0
votes
0
answers
66
views
Handling Stock Adjustment in Recursive CTE for Recipes with Shared Ingredients
I am working on a SQL Server 2016 database where I have recipes and ingredients stored in separate tables. The relationship between recipes and ingredients is stored in a junction table. I am using a ...
0
votes
1
answer
76
views
Type-erase owner in self-referential crates
I have a struct, and want to define another struct that references its field.
struct Tweet {
text: Text
}
#[ouroboros::self_referencing]
struct BorrowedText<Owner> {
owner: Arc<Owner>,...
0
votes
1
answer
62
views
I have 2 models need to references, but first model is a self-referential association
My lab
rails new test1 -d mysql
rails g scaffold User name
rails g migration AddTeacherToUsers #add_reference :users, :teacher, index: true
rails g scaffold Lab name user:references
rails db:create ...
0
votes
1
answer
121
views
Referencing history within the identifier [PineScript v5]
I want to reference to the history of the identifier in the same line. It is probably not possible this way. But it works in thinkorswim. I would want the signal either print +1 or -1 else print the ...
0
votes
1
answer
200
views
Rust self-referencing struct with a hashmap and vec indexes
I need to build an index, where first I check if a string already exists in the store vector, or if not, add it to the store and get its position in it.
Once done, I will need to consume the store, ...
2
votes
1
answer
207
views
How do I draw reflexive association if there are inheritance
My teacher gave us a homework to draw a class diagram using something
like this
class PersonRole{}
class Employee{
isA PersonRole;
}
class Manager {
isA Employee;
0..1 -- * Employee;
}
I know in ...
4
votes
1
answer
1k
views
Delete Prisma self-referencing (one to many)
I have this prisma schema
model Directory {
id String @id @default(cuid())
name String?
parentDirectoryId String?
userId String
parentDirectory ...
0
votes
1
answer
77
views
Function body for a function that consumes a compound data list of universities and produces the name of school with the lowest tuition. BSL RACKET
Hello everyone Im having trouble coding the body for a function that
consumes a compound data list of universities and produces the name of the university with the lowest tuition.
The language is BSL ...
0
votes
1
answer
100
views
Given an adress, how can I access the object in Python?
How can I access a Python object by it's address that I get from id(self.__dict__)?
The background is the following, I want to access one class instance from the other (both classes mimic custom ...
0
votes
1
answer
290
views
Is it okay to use 'static for references to Box in self referential structs?
Given the code snippet below:
use std::{io::BufWriter, pin::Pin};
pub struct SelfReferential {
pub writer: BufWriter<&'static mut [u8]>, // borrowed from buffer
pub buffer: Pin<...
-1
votes
1
answer
80
views
How do I use a class variable inside of that class? (C++)
This is the code I'm trying to run:
class poly {
public:
int vnum;
vrtx vrts[this->vnum];
};
(Note: The class name "poly" and other class "vrtx" are named ...
0
votes
1
answer
255
views
How to create self-referential AST in Rust?
Let's imagine we have a very simple AST for programming language with only functions and calls
use std::sync::Arc;
struct Function {
pub body: Vec<Call>
}
struct Call {
pub function: ...
0
votes
2
answers
75
views
Symfony project - Doctrine Self-Reference issue
I am working on a Symfony 6.1 project and have the following situation. I have an entity called "MaterialGroup". A material group can be in a parent-child relation with itself so one ...
1
vote
1
answer
80
views
How does Vec::push work for self referencing types?
Quoted from vec::push implementation:
pub fn push(&mut self, value: T) {
// This will panic or abort if we would allocate > isize::MAX bytes
// or if the length increment would overflow ...
0
votes
1
answer
39
views
Rails includes for self-referential associations
I have these tables:
Category: id, name, parent_id
CategoryImage: id, url, category_id
CategoryImageHistory: id, user_id, category_image_id
parent_id of Category is a foreign key to another Category ...
1
vote
1
answer
4k
views
Excel - How to count number of rows above cell
I am trying to create a single-column dynamic range and refer to it in the same column but all examples google throws up use the entire column, with the referencing cell in a separate column.
I will ...
0
votes
1
answer
203
views
Implementing a "virtual" method returning *this (covariant return type)
I'm writing a hierarchy of classes of C++, let's say A, B inheriting A, C inheriting A, and D inheriting B.
Now, all of these classes must have a method bar() &, whose body is:
{
A::foo();
...
2
votes
2
answers
221
views
How to avoid infinite loop in zipWith a self reference?
I'd like to create a list data structure that can zipWith that has a better behavior with self reference. This is for an esoteric language that will rely on self reference and laziness to be Turing ...
0
votes
1
answer
975
views
Retrieving Parents and Children - Self Referencing Entity gorm
I have a table that have a hierarchy structure with a parent having many children and a children having many parents.
As an example the following struct:
type User struct {
gorm.Model
Name ...
0
votes
3
answers
180
views
Dependencies between attributes of 2 and more classes
Is it possible to initialize instances of classes with attributes that are dependent across (not in circular way)?
Today, I use dictionaries instead of classes as follows:
dictA = {'A1': 10}
dictB = {'...
0
votes
1
answer
89
views
Can R list refer its own objects?
Is it possible for a list in R to refer its own objects, while defining it?
Example:
ui_names <- list(
gen_button = 'Generate Report',
gen_description = sprintf("Press '%s' button to ...
0
votes
1
answer
130
views
Pinescript: Old scripts with self-referencing variables
I have to old scripts (V2) I want to modify only for myself and dont reach out anyone to help me out with my bad coding skills ;)
The code looks that way:
weight = s(abs(change(close)))
c = weight * ...
0
votes
0
answers
64
views
How can a class reference itself through `std::array<>` iterators in C++?
The following class would not compile because it has an incomplete type for self-reference.
class SelfRef{
using DependencyReference = std::array<SelfRef, 10>::const_iterator;
public:
std::...