|
1 | 1 | use ruff_text_size::TextRange;
|
2 | 2 |
|
3 |
| -use crate::{constants::{OYarn, SymType}, core::evaluation::Evaluation, oyarn, threads::SessionInfo}; |
4 |
| -use std::{cell::RefCell, rc::{Rc, Weak}}; |
| 3 | +use crate::{constants::{OYarn, SymType}, core::evaluation::{ContextValue, Evaluation}, oyarn, threads::SessionInfo, Sy}; |
| 4 | +use std::{cell::RefCell, collections::HashMap, rc::{Rc, Weak}, u32}; |
5 | 5 |
|
6 | 6 | use super::symbol::Symbol;
|
7 | 7 |
|
@@ -62,7 +62,14 @@ impl VariableSymbol {
|
62 | 62 | pub fn get_relational_model(&self, session: &mut SessionInfo, from_module: Option<Rc<RefCell<Symbol>>>) -> Vec<Rc<RefCell<Symbol>>> {
|
63 | 63 | for eval in self.evaluations.iter() {
|
64 | 64 | let symbol = eval.symbol.get_symbol(session, &mut None, &mut vec![], None);
|
65 |
| - let eval_weaks = Symbol::follow_ref(&symbol, session, &mut None, false, false, None, &mut vec![]); |
| 65 | + let mut context = None; |
| 66 | + if let Some(parent) = self.parent.as_ref() { |
| 67 | + // To be able to follow related fields, we need to have the base_attr set in order to find the __get__ hook in next_refs |
| 68 | + // we update the context here for the case where we are coming from a decorator for example. |
| 69 | + context = Some(HashMap::new()); |
| 70 | + context.as_mut().unwrap().insert(Sy!("base_attr"), ContextValue::SYMBOL(parent.clone())); |
| 71 | + } |
| 72 | + let eval_weaks = Symbol::follow_ref(&symbol, session, &mut context, false, false, None, &mut vec![]); |
66 | 73 | for eval_weak in eval_weaks.iter() {
|
67 | 74 | if let Some(symbol) = eval_weak.upgrade_weak() {
|
68 | 75 | if ["Many2one", "One2many", "Many2many"].contains(&symbol.borrow().name().as_str()) {
|
|
0 commit comments